L
L
Lomoson2014-08-01 09:46:05
MySQL
Lomoson, 2014-08-01 09:46:05

How to do a JOIN on another table that doesn't have a value?

There are two tables:
7e6d098dfd4d4ac390338f4c3ed292df.png
Tell me, please, how to make a query to get:
695b3340cf054f4096fc32a8316473e6.png
Something like this comes to mind:

SELECT t1.id FROM `table1` as t1
LEFT OUTER JOIN `table2` as t2
ON t1.id=t2.id_table1
where t2.le_va=1 
order + limit

But it's not right.
If you add empty lines with le_va=1, then everything turns out beautifully, but in a real project this is not an option. there will be an unrealistically many empty lines.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2014-08-01
@Lomoson

where t2.le_va=1 or t2.le_va is null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question