SQL 语句解释:从 sys_user 表中查询用户数据
这个 SQL 语句从 sys_user 表中选择用户的全名和手机号,以及 sys_dept 表中的名称。其中,sys_user 表和 sys_dept 表通过 dept_id 进行内部连接,而 work_record 表则通过 create_by 进行左连接。最后,筛选出 create_by 为 NULL 且 created 日期为 '2023-4-14' 的记录。
SELECT
su.full_name,
su.mobile,
sd.`name`
FROM
sys_user su
INNER JOIN sys_dept sd ON sd.id =su.dept_id
LEFT JOIN work_record wr ON wr.create_by = su.id
WHERE
wr.create_by IS NULL AND DATE(wr.created) = '2023-4-14'
原文地址: https://www.cveoy.top/t/topic/nsZD 著作权归作者所有。请勿转载和采集!