[英]SQL query that merges two tables together with a where clause
Hi I want to search through table 2 with a value (names CustID) from table 1, and if all the values are found in table 2 (CustID) that matches table 1 (CustID) the values must be shown together with all the values from table 1 that does not match table 2's values. 您好我想在表2中搜索表1中的值(名称CustID),如果在表2(CustID)中找到与表1(CustID)匹配的所有值,则必须将值与所有值一起显示表1与表2的值不匹配。
Is it possible to do it this way and if it is can you please show me how, I need this for a project. 是否可以这样做,如果可以,请告诉我如何,我需要这个项目。
Thanks in advance 提前致谢
It sounds like you want a "LEFT" JOIN, which will pull up all records in table1 plus the matching ones in table2. 听起来你想要一个“LEFT”JOIN,它将拉出table1中的所有记录以及table2中的匹配记录。
SELECT A. ,B. SELECT A. ,B。 FROM table1 A LEFT JOIN table2 B ON A.CustID = B.CustID
FROM table1 LEFT JOIN table2 B ON A.CustID = B.CustID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.