过滤不同表中不可用的名称 [英] Filters the Name which is not available in the different Tables
问题描述
我有2个不同的表A和B.在表A中,我有id,name和表B,我有id,name并且在两个表中都有一些值。
Ex:
Id Name
F001 A >
F002 B
F003 C
F004 D
F005 E
Id Name
F002 B
F001 A
F005 E
现在,我必须从表A中获取表B中的缺失值。
是否有任何sqlite查询。如果没有,请给我这个案例的解决方案。
Ans应该是这样的。
身份证号码
F003 C
F004 D
提前致谢。
I have 2 Different tables A and B. In Table A, i have id,name and in Table B, i have id,name and have some values in both tables.
For Ex:
Id Name
F001 A
F002 B
F003 C
F004 D
F005 E
Id Name
F002 B
F001 A
F005 E
Now, i have to get the missing values in table B from table A.
Is there any sqlite query for that. If no, Please give me the Solution for this case.
Ans Should be like this.
Id Name
F003 C
F004 D
Thanks in advance.
推荐答案
尝试:
Try:
SELECT A.ID, A.Name FROM TableA A
LEFT JOIN TableB B ON B.name = A.name
WHERE B.ID IS NULL
我重读了你的标题并实现了你只想知道TableB中哪些名字不在TableB中。
例如:
I reread your title and realized you just want to know which names are not in TableA that are in TableB.
For example:
SELECT Name
FROM TableB
WHERE Name NOT IN (SELECT NAME FROM TableA)
尝试EXCEPT
运营商 [ ^ ]:
Try theEXCEPT
Operator[^]:
SELECT
ID,
Name
FROM
TableA
EXCEPT
SELECT
ID,
Name
FROM
TableB
;
如果您只想要缺少名称:
If you just want the missing names:
SELECT
Name
FROM
TableA
EXCEPT
SELECT
Name
FROM
TableB
;
这篇关于过滤不同表中不可用的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!