Kiran Baroliya
Kiran Baroliya

Reputation: 13

I want row where max id

My query

select max(forum_id) as f_id from forum where topic_id='$fo_id';

We want all row record where forum_id is maximum. My query is as above. We success to get Maximum Forum_id but We want entire row where max forum_id. Can you help me?

Upvotes: 0

Views: 95

Answers (3)

Nahid Bin Azhar
Nahid Bin Azhar

Reputation: 763

You can try

select * from forum where topic_id='$fo_id' order by forum_id desc

I think it will work.

Upvotes: 0

Lalit Sharma
Lalit Sharma

Reputation: 565

You can try below given query.

 SELECT * from tabName where `tabId` IN (select MAX(tabId) from tabName);

Upvotes: 1

Ashique C M
Ashique C M

Reputation: 683

try this:

SELECT * FROM forum WHERE topic_id='$fo_id' ORDER BY forum_id DESC LIMIT 0, 1;

Upvotes: 2

Related Questions