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 361,569 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 2,063 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.
Please support our MySQL advertiser:
Views: 591 | Replies: 4
Reply
Join Date: May 2008
Posts: 3
Reputation: deepmann97 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
deepmann97 deepmann97 is offline Offline
Newbie Poster

Data from Multiple Tables

  #1  
May 17th, 2008
Hello Friends,
I have three table and i want to select data from them
Table 1
Roll No. --- Name---Age
1------------a--------12
2------------b--------13

Table 2
Roll No.---Name---Age
7------------d------12
8------------b------13
9------------c------12

Table 10
Roll No.---Name---Age
41---------d---------12
43---------b---------13
44---------c---------12

Table 3
Roll No.---Sex
1------------f
7------------f
41----------f

i want to select date from Table 1 and Table 2 and Table 3 only for the Rolle No. 1 and 7. i tried inner loop. total table are 10. I want to display age and sex.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 243
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Data from Multiple Tables

  #2  
May 17th, 2008
hi deepman,
try this
  1. SELECT t.rollno, t.age, s.sex FROM table1 t
  2. JOIN table3 s ON t.rollno = s.rollno
  3. WHERE s.rollno = 1 OR s.rollno = 7
  4. union
  5. SELECT t.rollno, t.age, s.sex FROM table2 t
  6. JOIN table3 s ON t.rollno = s.rollno
  7. WHERE s.rollno = 1 OR s.rollno = 7
  8. union
  9. SELECT t.rollno, t.age, s.sex FROM table10 t
  10. JOIN table3 s ON t.rollno = s.rollno
  11. WHERE s.rollno = 1 OR s.rollno = 7
So far, i didn't test it.
what is the reason, that you have split the data over various tables?

krs,
tesu
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: deepmann97 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
deepmann97 deepmann97 is offline Offline
Newbie Poster

Re: Data from Multiple Tables

  #3  
May 18th, 2008
tesuji

actualy have 10 tables for different classes.
Table A for Batch 1
___________________
Roll No. | Name | Age
A1 aa 12
A2 ab 13
A3 bb 12

Table B for Batch 2
___________________
Roll No. | Name | Age
B1 ac 12
B2 ad 13
B3 ba 12

Table c for Batch 3
___________________
Roll No. | Name | Age
C1 ae 12
C2 ad 13
C3 bd 12

Table S for Batch 2
___________________
Roll No. | Sex
A1 f
B3 f
C2 f

I want to select details from table A,B,C for the Roll No. in table S
Reply With Quote  
Join Date: Apr 2008
Posts: 243
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Data from Multiple Tables

  #4  
May 18th, 2008
So the advised select should function correctly. Solely just out of curiosity, did you true check the advised select on your database? Possibly you might have done some modification of it.
Reply With Quote  
Join Date: Dec 2007
Posts: 94
Reputation: mwasif is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
mwasif mwasif is online now Online
Junior Poster in Training

Re: Data from Multiple Tables

  #5  
May 18th, 2008
Why are you creating separate tables for each batch? You can save all your data only by adding a new column batch in a table and saving corresponding batch in the field.
Reply With Quote  
Reply

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

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

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

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