« Previous - - Next »

[mysql] sql query: combine two table

28 August 2007

combine two tables, count specific values, order by the count, and show only top 10.

SELECT table1.comment_id comment_id, count(table1.comment_id) point, parent_id, subparent_id, text FROM table1 LEFT JOIN comments ON table1.comment_id=table2.comment_id WHERE board_id=1 GROUP BY table1.comment_id ORDER BY point DESC LIMIT 10

Posted in programming | Trackback | del.icio.us | Top Of Page

No comments yet

Leave a Reply