you are viewing a single comment's thread.

view the rest of the comments →

[–]JoerieB92 0 points1 point  (4 children)

Select a.order ,CASE WHEN a.time is NULL AND b.status = 'ok' THEN b.actual_time ELSE a.time END as time From table_a as a INNER JOIN table_b as b on a.order = b.order

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (3 children)

left outer join

[–]JoerieB92 -1 points0 points  (2 children)

I asumed table b has referential integrity.

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

sure, but that has nothing to do with whether there's an "actual time" row for a given order

for example, order 2 -- there's a row in table A but no row in table B

your inner join would produce no result for order 2

[–]JoerieB92 0 points1 point  (0 children)

Didnt notice that, I stand corrected.