If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > query from 3 tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-03, 10:00
segovia6969 segovia6969 is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
query from 3 tables

Hello,
I'm having a problem with this:
I have 3 tables.
Two of them together have the same information as the third one, with the difference that they have different field names and the two first have a little bit more info about other things.
I want to do a query and show the info that I want in one table, which must have common field names.

For example, one table has this fields:
-user
-documents

the other two tables have this info:
Table 1:
-user
-id
Table 2:
-document
-id

(The users and documents from the first table are different as the other tables.)
I want make a single table with the fields "user" and "documents" and have the users and documents of all 3 tables in there.
How can I do this? Is this possible? Where could I get more information about this?
Many thanks.

Nacho
Reply With Quote
  #2 (permalink)  
Old 11-05-03, 12:28
Mincer Mincer is offline
Registered User
 
Join Date: Sep 2003
Location: London
Posts: 56
You need to read up on UNIONs

SELECT blah FROM table 1
UNION
SELECT blah FROM table2

Regards,

Matt.
Reply With Quote
  #3 (permalink)  
Old 11-05-03, 13:24
segovia6969 segovia6969 is offline
Registered User
 
Join Date: Nov 2003
Posts: 6
I'll do it...thanx for your help!
Greetings,

Nacho

PS: It works. Thanx again!

Last edited by segovia6969; 11-05-03 at 14:14.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On