project - Selecting values based on other values SQL? -
i wasn't sure title question, apologize if title misleading.
i have 2 columns in table movieid
, format
(i have more, these ones focusing on.
there 2 types of values in 'format' column: 'dvd' , 'blu-ray'. want select movies have dvd format. note there multiple movies have blu-ray , dvd format, not want display these values. see fiddle below sample of data. thank you!!!
movieid | format ----------------- 1000 dvd 1000 dvd 1000 blu-ray 1001 dvd 1001 dvd 1002 dvd 1003 dvd 1003 blu-ray 1004 dvd
i want output
movieid ------------ 1001 1002 1004
one straightforward way accomplish follows:
select distinct (movieid) movies m format='dvd' , not exists ( select * movies mm mm.movieid=m.movieid , mm.format='blu-ray' )
this pretty translation of english description of problem sql syntax.
Comments
Post a Comment