Reputation: 1363
How can I make this exclude the row if any of the (stage1_choice, stage2_choice or stage3_choice) values = null ?
I've tried:
SELECT r.breakout_id ,
r.case_id ,
r.stage_id ,
r.chart_id ,
s.stage1_choice ,
s.stage2_choice ,
s.stage3_choice
FROM Results AS r ,
Submissions AS s
WHERE r.breakout_id = '1'
AND s.breakout_id = '1'
AND r.case_id = s.case_id
AND stage_id < 4
AND s.stage1_choice NOT NULL
AND s.stage2_choice NOT NULL
AND s.stage3_choice NOT NULL
But it still returns rows that contain a null in one of the columns.
Upvotes: 1
Views: 517
Reputation: 4509
try
SELECT r.breakout_id, r.case_id, r.stage_id, r.chart_id, s.stage1_choice, s.stage2_choice, s.stage3_choice
FROM Results as r, Submissions as s
WHERE r.breakout_id = '1' AND s.breakout_id = '1' AND r.case_id = s.case_id AND stage_id < 4 AND s.stage1_choice NOT NULL AND s.stage2_choice IS NOT NULL AND s.stage3_choice IS NOT NULL
or
SELECT r.breakout_id, r.case_id, r.stage_id, r.chart_id, s.stage1_choice, s.stage2_choice, s.stage3_choice
FROM Results as r, Submissions as s
WHERE r.breakout_id = '1' AND s.breakout_id = '1' AND r.case_id = s.case_id AND stage_id < 4 AND s.stage1_choice != '' AND s.stage2_choice != '' AND s.stage3_choice != ''
Upvotes: 1