Answer the question
In order to leave comments, you need to log in
MYSQL LEFT JOIN returns NULL on empty table?
How? Why? The tables are empty.
SELECT
st.*, MAX(sp.date) as last_date,
SUM(case when sp.user_id != 3 then sp.status end) as unread
FROM support_ticket st
LEFT JOIN support_message sp ON sp.ticket_id = st.id
WHERE st.user_id = 3
ROW COUNT (1)
+-----------------------------------------------------------------------------------------------------------------+
| id | user_id | title | service | type | express | status | open_date | close_date | last_date | unread |
+-----------------------------------------------------------------------------------------------------------------+
| NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
+-----------------------------------------------------------------------------------------------------------------+
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question