SELECT today.status, GROUP_CONCAT(tomorrow.work_order order by line), today.code, today.events
FROM today LEFT JOIN tomorrow
ON today.code = tomorrow.code
WHERE today.status like '1%' or
(today.status like '3%' and tomorrow.work_ordertext is null)
GROUP BY today.code
I am having issues with the ‘tomorrow.work_ordertext is null’ statement. tomorrow.code and tomorrow.work_ordertext may not even exist in the table, so I am guessing it shouldn’t really be a null statement. I am looking for a way to pull rows from the today table if no records exists on the tomorrow table once the status is like 3 in the today table. Sorry if it sounds confusing.
I took out the like for the status as it will match 1, 10, 1b, 1somethingweird.