MySQL Forums
Forum List  »  Newbie

JOIN fields from multiple tables
Posted by: Christian Schaefer
Date: February 02, 2005 03:17AM

hi all,

I have a database here that stores data for a net magazine. there are three different kinds of articles.

1. reviews
__________________________
|ID|CREATED|TITLE|REVIEW|...|
|01|timestmp| text |text |...|
--------------------------------------

2. interviews
_____________________________
|ID|CREATED|TITLE|INTERVIEW|...|
|01|timestmp| text |text |...|
-----------------------------------------

3. articles
__________________________
|ID|CREATED|TITLE|ARTICLE|...|
|01|timestmp| text |text |...|
--------------------------------------


each table has its own unique structure. the only columns that are present in all three of them are ID, CREATED and TITLE. CREATED is a timestamp set to the time, when the article/review/interview was created.

now I want to select from those three tables the five most recently created ones. having resulting table like this:


_________________________________________
|ID|CREATED|TITLE|REVIEW|INTERVIEW|ARTICLE|
|01|timestmp| text |text |NULL |NULL |
|02|timestmp| text |NULL |NULL |text |
|03|timestmp| text |NULL |text |NULL |
|04|timestmp| text |NULL |text |NULL |
-----------------------------------------------------------

but do I do it? how can I order by multiple columns at once and how can I join the three fields CREATED to one resulting column?


thanks in advance!


regards
/christian

Options: ReplyQuote


Subject
Written By
Posted
JOIN fields from multiple tables
February 02, 2005 03:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.