Answer the question
In order to leave comments, you need to log in
How to get any one record from a table, with the condition that there will be no record with a certain value in the associated table?
There is an `order` table and a `task` associated with it.
I need to get any one order that is not fulfilled by a certain executor (let's say with ID: 5)
SELECT `order`.* FROM `order`
LEFT JOIN `task` ON `order`.`id` = `task`.`order_id`
WHERE (`order`.`status`=10) AND
(`order`.`type`='10') AND
(`task`.`executor_id` != 5)
LIMIT 1
Answer the question
In order to leave comments, you need to log in
Instead
of (`task`.`executor_id` != 5)
you need to write
(`task`.`executor_id` is null)
where 5 came from is completely incomprehensible.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question