Home >Backend Development >PHP Tutorial >How to query users without orders in Mysql?
Suppose there is an Order table and a User table. How should I query all users who do not have orders in one statement?
Suppose there is an Order table and a User table. How should I query all users who do not have orders in one statement?
The fields of at least two tables must be given, and the relationship between them must be made clear...
select userid from user where userid not in (select distinct userid from order)
roughly like this