How to get data from multiple tables?

zerocool

I am using PHP. I have following tables

1)Posts

||  post_id  |  post  |  date_posted  ||


2) Photo

||  photo_id  |  photo  |  date_posted||


3) Video

||  video_id  |  video  |  video_link  |  date_posted||

I want to retrieve all rows present in all tables and order by date_posted.

I want to differentiate later after retrieving rows which one is video and which one is post

How can i do this?

Snow Blind
SELECT post_id as id, post as data, date_posted FROM Posts
UNION ALL
SELECT photo_id, photo, date_posted FROM Photo
UNION ALL
SELECT video_id, video, date_posted FROM Video
ORDER BY date_posted DESC

maybe?..

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related