Jump to content


Seeking help with getting resultset from multiple tables

  • Please log in to reply
1 reply to this topic

#1 Red 09

Red 09
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationNorway

Posted 03 November 2003 - 11:42 AM

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?
- Red -

#2 sirmanson

  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationTucson, AZ USA

Posted 13 November 2003 - 07:26 PM

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users