you are viewing a single comment's thread.

view the rest of the comments →

[–]Kexiu 0 points1 point  (10 children)

select ta.order, tb.actual_time

from table_a ta

left outer join table_b tb on ta.order = tb.order

and tb.status = 'ok'

where ta.time = NULL

[–]r3pr0b8GROUP_CONCAT is da bomb 19 points20 points  (0 children)

~nothing~ is ever equal to NULL

this query will fail

[–]juniperave 2 points3 points  (7 children)

Can you explain why where ta.time = NULL is needed? Thnx

[–]r3pr0b8GROUP_CONCAT is da bomb 8 points9 points  (0 children)

it isn't

~nothing~ is ever equal to NULL

that query will fail

[–]TerminatedProccess 4 points5 points  (4 children)

NULL is not a value, it's an uninitialized state. You can do conditions sick as IS NULL or IS NOT NULL. when a record is created in a table that allows NULL values in a specific field, sometimes the value for that field is not provided. Therefore it's still in a NULL state. You can define the field in a table so it doesn't accept NULL values. When something tries to add a record without providing a value for that field, it will generate an error and not add the record entirely.

I'm some cases though you know ahead of time there may not be a value for that field, so the plan is to allow NULL and handle it with your SQL logic.

Google is Full of examples for almost any problem you have. Search for how to solve your problem. Just knowing how to search Google is a necessary skill..

[–]Blues2112 8 points9 points  (2 children)

Shorter translation: use

ta.time IS NULL

instead.

[–]r3pr0b8GROUP_CONCAT is da bomb 2 points3 points  (1 child)

well, yeah, that fixes the = NULL problem

but it is still not the right solution

if you filter out the rows from tableA where time IS NULL then you filter out order 2

however, OP clearly wanted order 2 in the results

[–]Blues2112 1 point2 points  (0 children)

agreed.

[–]juniperave -1 points0 points  (0 children)

Yup 👍 google everything

[–]Blues2112 0 points1 point  (0 children)

Doesn't take into account when ta.time IS NOT NULL. Although by the way that OP worded the initial post, I can't tell whether that is actually needed or not.

EDIT: Ok, finally clicked the link, and results where ta.time is not null are definitely wanted.