Jump to content

Archived

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

Red 09

Seeking help with getting resultset from multiple tables

Recommended Posts

I\'m trying to make a \'most recent entries\' list for my intranet site.

 

I want his list to show the last 10 entries from 3 or more tables.

 

I only want it to show entries the user has access to (I use a very simple function to check the users access level in the category for each entry).

 

 

I can\'t figure out how to make a mysql query that returns certain fields from the 3 or more tables, and sorts them after the \'date published\'-field in each table, and filters out expired items based on the \'expire date\'-field (the names of these fields are not the same in all the tables).

 

If I can get this far, I\'m going to try and make a loop in php that checks the users access against each entry in the result untill 10 are found.

 

 

Can anyone help?

Share this post


Link to post
Share on other sites

I would recommend storing some sort of access level in your tables and letting mySQL filter the results based on that.

 

 

select t1.*,t2.*, t3.*

from table1 t1,

inner join table2 t2 on t1.id=t2.id

inner join table3 t3 on t2.id=t3.id

where t1.user_level<=$user_level

and t2.user_level<=$user_level

and t2.user_level<=$user_level

order by t1.date_published

Share this post


Link to post
Share on other sites

×

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.