SELECT `project`.* FROM `project` LEFT JOIN `project_to_app` ON `project`.`project_id` = `project_to_app`.`project_id` WHERE (`project`.`created_by`=2) AND (`project_to_app`.`app_id`<>'userapp56g') I have a problem understanding the query construction. There are 4 tables: project , project_to_app , app , user . Only the first two participate in the request. project_to_app is a link table containing the fields id , project_id , app_id .
My task is to list the projects created by the user with id = 2 ( project . created_by = 2), where created_by is a link to the user table in the project table, and not belonging to the current application ( project_to_app . app_id <> 'userapp56g'), where ' userapp56g 'is the id of the current application. The request returns an empty response to me, although there are two projects, both belong to the current user, but there is only one connection with them. Help to understand where the flaw in the logic?