User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 401,487 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,236 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 633 | Replies: 7
Reply
Join Date: Nov 2007
Posts: 181
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

query

  #1  
Jun 11th, 2008
hi
I want to fetch data from four tables using a single query.please tell me how to do that.
thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: query

  #2  
Jun 11th, 2008
Originally Posted by lydia21 View Post
hi
I want to fetch data from four tables using a single query.please tell me how to do that.
thanks in advance

try select * from a, b, c, d

then sort out at your leisure
Reply With Quote  
Join Date: Jun 2008
Posts: 40
Reputation: varmadba is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
varmadba varmadba is offline Offline
Light Poster

Re: query

  #3  
Jun 13th, 2008
  1. SELECT table1.*,table2.*,table3.*,table4.* FROM table1
  2. INNER JOIN table2
  3. ON table1.column1=table2.column1
  4. INNER JOIN table3
  5. ON table1.column1=table3.column1
  6. INNER JOIN table4
  7. ON table1.column1=TABLE.column1

change table names and column names accordingly
Last edited by peter_budo : Jun 14th, 2008 at 1:44 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Jun 2008
Posts: 40
Reputation: varmadba is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
varmadba varmadba is offline Offline
Light Poster

Re: query

  #4  
Jun 13th, 2008
put your create table syntax for all 4 tables
then some 1 can send a exact query
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: query

  #5  
Jun 13th, 2008
Originally Posted by varmadba View Post
put your create table syntax for all 4 tables
then some 1 can send a exact query


Obviously a task too overcharging him. Why not letting him doing plain cross products first a la posting #2 ?
Reply With Quote  
Join Date: Jun 2008
Posts: 40
Reputation: varmadba is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
varmadba varmadba is offline Offline
Light Poster

Re: query

  #6  
Jun 13th, 2008
select * from a, b, c, d
this will produce a Cartesian output

say you have 100 rows in each table
o/p will be 100 x 100 x 100 x 100

you know why it doesn't have how to join tables
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: query

  #7  
Jun 13th, 2008
correct, it is cartesian product, not cross product. thank you, varmadba

True, the cardinality is just the total product of the cardinalities of all involved tables. But this might be ok to him. So he would learn how to figure out the essential rows manually doing true handiwork.
Reply With Quote  
Join Date: Jun 2008
Posts: 40
Reputation: varmadba is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
varmadba varmadba is offline Offline
Light Poster

Re: query

  #8  
Jun 13th, 2008
did i write Cross product in my post,
if so my my...

how feasible it is to handwork output if you have trusted DB to do that

dont think so...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 2:12 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC