0

删除表行的典型查询通常是这样的,对吧?

$query1 = odbc_exec($conn, "DELETE FROM table1 WHERE uname1 <> uname2");

但是如果我想要它在uname2不同的表中呢?

4

2 回答 2

3
DELETE FROM table1
WHERE uname1 NOT IN (
    SELECT uname2
    FROM table2
)
于 2013-06-27T13:48:14.787 回答
0

如果uname1是唯一的,您可以执行以下操作:

DELETE FROM table1 AS t1
WHERE uname1 NOT IN (
    SELECT uname2
    FROM table2 AS t2
    WHERE t2.uname1 = t1.uname1
);
于 2013-06-27T13:49:12.713 回答