mnroff

Just another WordPress.com site

Category Archives: SQL

How get amount of related records from other related table

SELECT
    ft.forum_theme_id, ft.title, (
        SELECT count(fm.forum_message_id) from forum_messages fm where fm.forum_theme_id=ft.forum_theme_id ) AS msgs
FROM forum_themes ft

Advertisements