i have 'topic' and 'comment' fields in table of database ,when some one give comment on topic no 1 ,it save in dabase with topic number and comment,
i want show topic number with higest comment.
tell me sql query to show result

Recommended Answers

SELECT count(*) AS count, topic 
FROM comments 
GROUP BY topic
ORDER BY count DESC LIMIT 1
Jump to Post

All 3 Replies

SELECT count(*) AS count, topic 
FROM comments 
GROUP BY topic
ORDER BY count DESC LIMIT 1

nt show topic number with higest comment.
tell me sql query to show result

tell me same query if my table name is 'orange'

I am sure you can do that yourself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.