[thelist] mysql query syntax using max(id)
rudy
r937 at interlog.com
Sat Oct 5 23:41:00 CDT 2002
> The goal of the query is to select the highest 'news_id'
> and display the 'news_article' for only that id. Any tips?
in any other database besides mysql,
select news_id, news_article
from sb_news
where news_id =
( select max(news_id) from sb_news )
won't work in mysql because it doesn't support subqueries
however,
select news_id, news_article
from sb_news
order by news_id desc
limit 1
is a viable alterative
rudy
More information about the thelist
mailing list