MySQL: check the entire column if any row matters

I want to conditionally switch if all rows are empty for a column audio. I tried with type GROUP BY but it doesn't work.

  SELECT postid, title, has_audio, audio, type 
  FROM qa_posts 
  WHERE parentid=1

enter image description here

So, if sound exists for the entire column for this parent identifier, which executes code A, if not code B

+5
source share
3 answers

count , audio NULL. .., , , , , . , - , - , :)

,

-, , are all rows' audio column empty? . . : how many of rows are not null are all rows' audio column empty?, , 5, 10 100000. , "" if there any row that is NOT null?. , , , .

, if there any row that is NOT null?, , audio NOT NULL. " " , 1 " " , SQL LIMIT 1, DB , , , . .

. ( ), , audio NULL , , - ( , , ), if there any row that is NOT null? ", " ( ).

+6

select select count(*) WHERE audio != null. , . , .

+2

You can just check the lines NOT NULLlike

SELECT * FROM `table` WHERE column IS NOT NULL AND column <> ''
+1
source

All Articles