SELECT users.group_id, testtb.id
FROM users
LEFT JOIN testtb on users.group_id =testtb.id
where testtb.id is not null ORDER BY users.group_id


在我上面的查询中,如果where我想再使用一个where testtb.name is not null条件(即testtb.id is not null

最佳答案

您可以使用AND子句

    SELECT users.group_id, testtb.id FROM users
    LEFT JOIN testtb on users.group_id =testtb.id
    AND testtb.id is not null
AND testtb.name is not null
    ORDER BY users.group_id;

10-04 16:50