views:

36

answers:

1

I have a query below and would like to know if it is possible to get more than 1 result. I would like to get the 4 most recent entries.

Thanks!

select c.email,c.text,m.alertDataID  
from client_users as c, monitor_alerts as a, monitor_alerts_data as m
where c.id=a.userID and a.alertID=m.alertID and 
m.alertDataID = (SELECT alertDataID FROM monitor_alerts_data ORDER BY alertDataID DESC LIMIT 1) 
LIMIT 4
+3  A: 

Use IN instead of =:

 ... and m.alertDataID IN (SELECT alertDataID FROM ...)

Also don't limit your subquery to LIMIT 1. You'll need LIMIT 4 in the sub-query.

wuputah
digitalbart
Don't use a LIMIT at all in the subquery then, simply limit your outer result set. PS. What version of MySQL are you using?
wuputah
That worked... thanks BTW I am using 5.0.51a-3
digitalbart