E
E
Eugene2019-09-18 13:22:24
MySQL
Eugene, 2019-09-18 13:22:24

How to change this SQL query?

t1 id, t2id, num
t2 id, name, typeid
t3 id, name
SELECT t1.id, t2.name, t3.name
FROM t1
JOIN t2 ON t2.id = t1.t2Id
JOIN t3 ON t3.id = t2.typeid
WHERE num= 111
Works correctly. Is it possible to change the query so that the rows that have NULL in the t2.typeid field are also displayed from the tables?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2019-09-18
@kevin

JOIN t3 ON t3.id = t2.typeid OR t2.typeid IS NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question