E
E
Eserchik2017-07-06 10:51:23
MySQL
Eserchik, 2017-07-06 10:51:23

SQL query for not in set?

The people help with request (mysql).
Table of applications, Table of photos on applications.
I need to list the numbers of those orders that are not in the table with photos (i.e. I need a list of orders that do not have photos)
I do something like:
SELECT num FROM customerequipment WHERE num NOT IN (SELECT OrderID from attaches).
But returns null

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dobryshin, 2017-07-06
@Eserchik

As an option:

SELECT
    num
FROM customerequipment m
WHERE NOT EXISTS (
   SELECT
        1
   FROM attaches e
   WHERE e.OrderID = m.num
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question