编写此MySQL查询的更好方法(JOIN)
写这个查询的正确方法是什么?它当前不起作用,因为子查询返回多行。您可以使用中的编写此MySQL查询的更好方法(JOIN),mysql,Mysql,写这个查询的正确方法是什么?它当前不起作用,因为子查询返回多行。您可以使用中的执行此操作: DELETE FROM table1 WHERE field1=(SELECT id FROM table2 WHERE type=1) OR field2=(SELECT id FROM table2 WHERE type=1) delete from table1 where field1 in ( select id from table2 whe
执行此操作:
DELETE FROM table1
WHERE field1=(SELECT id FROM table2 WHERE type=1)
OR field2=(SELECT id FROM table2 WHERE type=1)
delete
from table1
where field1 in (
select id
from table2
where type = 1
)
or field2 in (
select id
from table2
where type = 1
)
您可以使用
中的执行此操作:
DELETE FROM table1
WHERE field1=(SELECT id FROM table2 WHERE type=1)
OR field2=(SELECT id FROM table2 WHERE type=1)
delete
from table1
where field1 in (
select id
from table2
where type = 1
)
or field2 in (
select id
from table2
where type = 1
)
在
中使用:
DELETE FROM table1
WHERE field1=(SELECT id FROM table2 WHERE type=1)
OR field2=(SELECT id FROM table2 WHERE type=1)
delete
from table1
where field1 in (
select id
from table2
where type = 1
)
or field2 in (
select id
from table2
where type = 1
)
在
中使用:
DELETE FROM table1
WHERE field1=(SELECT id FROM table2 WHERE type=1)
OR field2=(SELECT id FROM table2 WHERE type=1)
delete
from table1
where field1 in (
select id
from table2
where type = 1
)
or field2 in (
select id
from table2
where type = 1
)
根据表的大小,您可能可以使用IN方法。如果它们在较大的一侧,您可以使用语法进行删除
DELETE FROM table1
WHERE field1 IN (SELECT id FROM table2 WHERE type=1)
OR field2 IN(SELECT id FROM table2 WHERE type=1)
根据表的大小,您可能可以使用IN方法。如果它们在较大的一侧,您可以使用语法进行删除
DELETE FROM table1
WHERE field1 IN (SELECT id FROM table2 WHERE type=1)
OR field2 IN(SELECT id FROM table2 WHERE type=1)