tsql - SQL query, select row based on another row -


i have photo review application, sql server 2008 r2 back-end. 1 requirement me able mark photos anomalies such "bad lighting," "blurry," etc. option "unidentified."

whenever user chooses "unidentified," required add additional anomaly, called "other," , give description. can have "other" anomaly without "unidentified," not vice versa.

i need create report lists "other" anomalies, if picture has "unidentified" anomaly. no idea how write query accomplishes this. table has photoid, , anomalyid, , description text field "other," if required (plus other irrelevant stuff).

so, psuedocode be:

select photoid, description photo_anomalies photo anomaly "other" description not null, if there matching "unidentified" anomaly photoid.

clear mud?

i figured out solution - not sure if it's best seems work. using select = "unidentified" inner joined on photoid select = "other."


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -