开发者

Remove field form mysql

My database has two table

Table A contain two field开发者_开发知识库 (id,numar)

Table B contain two field (numar)

How to remove row form Table A AND B Where A.numar not exist B.numar AND B.numar not exist A.numar

Great thanks


Maybe this?

DELETE FROM TableA WHERE Numar NOT IN (SELECT Numar FROM TableB)
DELETE FROM TableB WHERE Numar NOT IN (SELECT Numar FROM TableA)

So if your tables had this data:

id|numar    id|numar
--------    --------
1 | 01      1 | 02
2 | 02      2 | 03
3 | 03      3 | 04
4 | 04      4 | 05

Then the first statement would remove row id 1 from the first table, and then the second statement would remove row id 4 from the second table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜