MySQL: Select pages that are not tagged?
Posted
by
lauthiamkok
on Stack Overflow
See other posts from Stack Overflow
or by lauthiamkok
Published on 2011-02-09T23:15:56Z
Indexed on
2011/02/09
23:26 UTC
Read the original article
Hit count: 200
Hi,
I have a db with two tables like these below,
page table
pg_id title
1 a
2 b
3 c
4 d
tagged table
tagged_id pg_id
1 1
2 4
I want to select the pages which are tagged, I tried with this query below but doesn't work,
SELECT *
FROM root_pages
LEFT JOIN root_tagged ON ( root_tagged.pg_id = root_pages.pg_id )
WHERE root_pages.pg_id != root_tagged.pg_id
It returns zero - Showing rows 0 - 1 (2 total, Query took 0.0021 sec)
But I want it to return
pg_id title
2 b
3 c
My query must have been wrong?? How can I return the pages which are not tagged correctly?
Thanks.
© Stack Overflow or respective owner