mysql - sql select records that don't have relation in a second table -
i trying run sql query in phpmyadmin in mysql database in order records not have corresponding records in table.
e.g.
**album** id, name **track** id, album_id, name i need album records not have relative track records.
i have tried
select album.id album album.id not in ( select track.album_id track 1 group track.album_id ) but unfortunately crashes mysql service
i have tried
select a.id album inner join track t on a.id = t.album_id t.id null but doesn't work expected (returns no results)
you can use exists check absence of record in related table.
select album.id album not exists ( select * track track.album_id = album.id ); see: http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
Comments
Post a Comment