Skip to content Skip to sidebar Skip to footer

Does Row Exist And Multiple Where

I just asked this question Multiple Where conditions, but realised there was more to it (and didn't want to confuse the other question). I have a table that looks like this: meta_i

Solution 1:

SELECT DISTINCT m1.id 
FROM metadata m1
WHERE 
    m1.meta_key = 'school' 
AND m1.meta_value = 'Some School 1' 
AND NOT EXISTS 
(
  SELECT * FROM metadata m2
  WHERE 
      m2.meta_key = 'hidden' 
  AND m2.meta_value = '1'
  AND m2.Id = m1.Id
)

Post a Comment for "Does Row Exist And Multiple Where"