1. In table table1, the field table2_id references the primary key field id of table table2. I need to query the data that exists in table table1 but does not exist in table table2. The final SQL is as follows. See Figure 1.

SQL
SELECT
*
FROM
`db1_20230810`.`table1`
WHERE
NOT EXISTS ( SELECT * FROM `db2_20230810`.`table2` WHERE ( `table2`.`id` = `table1`.`table2_id` ) AND ( `table2`.`deleted_at` IS NULL ) )
AND ( `table1`.`role` != 'development' )
AND (
`table1`.`deleted_at` IS NULL
)
