简体   繁体   English

SQL联接:联接两个表以将第二个表的结果转换为grep结果,然后

[英]SQL join: Join two tables to get the result from second tables to grep result and

I want to grep the Employee Unique Tax ID from first Tables to second starting like: 我想从第一个表到第二个表中复制Employee Unique Tax ID,例如: 在此处输入图片说明

select * from where Employee_ID as 'var1' Join on Employee_Catagory as 'var2' Join On Employee_Pos. as var3 . 

To get the Employee Unique_Tax_ID as $res I want to have it in a Sigle SQL Statement. 为了获得Employee Unique_Tax_ID作为$res我想在一个Sigle SQL语句中使用它。 The var1 -var3 value is not important because that can I change with PHP in that file with functions. var1 -var3的值并不重要,因为我可以使用该函数中的PHP更改该文件。

Simple LEFT JOIN should do: 简单的LEFT JOIN应该做:

select t1.employee_id,
    t1.employee_category,
    t1.employee_pos,
    t2.unique_tax_id
from table1 t1
left join table2 t2 on t1.system_id = t2.system_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM