且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从另一个表中获取数据? (MySQL的)

更新时间:2023-02-26 09:46:23

使用SQL Join子句。左外连接返回t1中的所有行,即使t2中没有相应的行



选择t1.name,t2.customer

t1 left外部联接t2在t1.EmployeeNo = t2.EmployeeNo和t2.status ='x'
Use a SQL Join clause. The Left outer join returns all rows in t1 even if no corresponding row in t2

select t1.name, t2.customer
t1 left outer join t2 on t1.EmployeeNo = t2.EmployeeNo and t2.status = 'x'