List:General Discussion« Previous MessageNext Message »
From:Kris Burford Date:March 18 2004 9:34am
Subject:select help - multiple where/limits
View as plain text  

wondering whether someone can set me straight on whether it's possible to 
request a set of records from a single table with multiple conditions.

for instance, a "story" table, containing id, title, text, section and 
published_date. what i would like is to retrieve is the 5 most recently 
published stories from each section (currently there are nine sections).

so, do i have to do this in nine separate queries or can i do something like:

SELECT id, title, text, sectioned, published_date
FROM stories
WHERE (section = 'events'  order by published_date desc limit 5) and 
(section = 'features'  order by published_date desc limit 5)


many thanks


select help - multiple where/limitsKris Burford18 Mar
  • Re: select help - multiple where/limitsVictoria Reznichenko18 Mar