Jump to content

[SOLVED] SQLQuery from 3 or more tables and sort them out according to time stamp.


andyhajime

Recommended Posts

Hey guys...

I never did this before and not sure if it's possible.  :shrug:

I need some advise for y'all the experts.

 

I've this task from a certain client and what he wants is - to list out all the comments within the website database onto a page, sort them out via latest date entry.

 

Sound simple right? Actually, to me it's not.

 

There are like over 5 modules in the website - eg: Blog, Gallery, Videos, ect.

...and each module has it's own table for comments to be stored.

 

- if comments posted in the gallery, it will be stored in "data_gallerycomment"

- if comments posted in the blog, it will be stored in "data_blogcomment"

- if comments posted in the video, it will be stored in "data_videocomment"

 

All the comments entries are separated/organized into it's own personal table. I noticed the columns on the comment tables are no difference for the other comment tables.

 

All have id, name, email, text, ip and date.

 

I figured that it's still possible to query the comments since the columns are replicates of one another. Only thing is I don't know how.

 

I know how to query a single table and ORDER BY date DESC or ASC, that sort of stuff. But to query a multiple tables at one time, that's beyond my IQ level in php.

 

Appreciate if you guys gimme some advised on how to do this.

If it's not possible then it's ok.

UNION... today I learn a new method.

Is there any difference between UNION ALL and UNION?

Just some random question for personal general knowledge..

 

Anyway, problem solved.

Thanks for the assistance man.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.