mysql - Select Items that don't have matching Items in another table -
tables _________________________ _________________________ |__________items__________| |_______readstatus________| |___itemid___|____data____| |___itemid___|___status___| | 1 | cats | | 1 | 1 | | 2 | dogs | | 2 | 1 | | 3 | fish | | | | ------------------------- -------------------------
i have 2 mysql tables similar shown above. need entries item table don't have corresponding status 1 in readstatus table. in example need entry data fish. i'm not familiar sql i'm not sure how based on other questions i've come this:
select * items inner join readstatus on items.itemid = readstatus.itemid readstatus.status != 1 this not work though because skips entries in items table don't have matching entry in readstatus table. adding status 0 entries search isn't option because create millions of entries. looks like, in phpmyadmin, merges entries 1 output don't want it's not dealbreaker.
any appreciated.
use left join instead of inner join:
select * items left join //left join readstatus on items.itemid = readstatus.itemid (readstatus.status != 1 or readstatus.status null); read left join tutorial.
Comments
Post a Comment