1

I have 2 tables A and b namely.

Table A has

+------+---------------+
|MANUID|LMD            |
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+
|1,001 |10/18/2013 7:13|
+------+---------------+

Table B has

+------+---------------------------------+
|MANUID|MANUFACTURERDESC                 |
+------+---------------------------------+
|1,001 |ACTION CONSTRUCTION EQUIPMENT LTD|
+------+---------------------------------+
|1,002 |AJAX FIORI ENGG (INDIA) PVT  LTD |
+------+---------------------------------+
|1,003 |APOLLO CONST. EQUIPMENT  PVT LTD |
+------+---------------------------------+
|1,004 |APOLLO INDUSTRIAL EQUIP.  PVT LTD|
+------+---------------------------------+
|1,006 |ASHOK LEYLAND                    |
+------+---------------------------------+
|1,007 |ATUL AUTO LTD                    |
+------+---------------------------------+
|1,009 |ATLAS COPCO INDIA LTD            |
+------+---------------------------------+

I want to remove MANUID from Table B which is not available in Table A. So from above my final Table B will be has only 1,001 in MANUID

4

4 回答 4

3
SELECT * FROM Table_B
WHERE MANUID IN
(SELECT MANUID FROM Table_A)

或者

SELECT * FROM Table_B
JOIN Table_A ON Table_B.MANUID = Table_A.MANUID

或者,如果您想删除记录:

DELETE * FROM Table_B
WHERE MANUID NOT IN
(SELECT MANUID FROM Table_A)
于 2013-11-12T13:29:56.410 回答
0

如果您使用 SQL 查询试试这个:

select tb.*
from Table B as tb, Table A as ta
where tb.MANUID = ta.MANUID
于 2013-11-12T13:33:09.997 回答
0

您可以SELECT使用INNER JOIN

SELECT * FROM TableA ta
INNER JOIN TableB tb ON ta.MANUID = tb.MANUID

INNER JOIN只会从 TableB 中选择MANUID字段与 TableA 匹配的记录。

然后DELETE他们:

DELETE FROM TableB 
WHERE MANUID NOT IN (SELECT MANUID FROM Table_A)
于 2013-11-12T13:35:09.843 回答
0

您应该使用 VLOOKUP 功能,这里有帮助: http:
//office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx

(我假设表 A 从单元格 A1 开始,表 B 从单元格 A11 开始)
在表 B 的第三列中,您应该写:
=vlookup(A11;A2:B8;2;0)
它会说:1,001

如果您将公式复制到下面的一行,您将看到“N/A”出现。
应删除每行带有“N/A”的行,因为这意味着您在表 A 中找不到该值。

(请注意,当您复制公式时,excel 会更改引用的单元格,因为您可以使用美元符号,这里有帮助:http ://www.notjustnumbers.co.uk/2011/05/excel-tip-dollar-sign-in-formula-fixing.html )

于 2013-11-12T13:41:56.243 回答