|
Удаление из одной таблицы по условиям, заданной в другой.
|
|||
---|---|---|---|
#18+
Коллеги! Есть такая проблема. Условие. Есть table1: id code name ... Есть table2: id Надо удалить из table1 записи, id которых совпадает с id из table2... delete from table1 where table1.id=table2.id; delete from table1, table2 where table1.id=table2.id; delete from table1 inner join table2 on table1.id=table2.id where table1.id=table2.id; К сожалению, приведженные выше примеры (и иже с ними) не работают:( ... |
|||
:
Нравится:
Не нравится:
|
|||
03.12.2002, 17:42 |
|
Удаление из одной таблицы по условиям, заданной в другой.
|
|||
---|---|---|---|
#18+
В принципе MySQL Manual :: DELETE исполняет это, но с версии 4.х помоему! The first multi-table delete format is supported starting from MySQL 4.0.0. The second multi-table delete format is supported starting from MySQL 4.0.2. The idea is that only matching rows from the tables listed before the FROM or before the USING clause are deleted. The effect is that you can delete rows from many tables at the same time and also have additional tables that are used for searching. The .* after the table names is there just to be compatible with Access: DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id or DELETE FROM t1,t2 USING t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id In the above case we delete matching rows just from tables t1 and t2. ... |
|||
:
Нравится:
Не нравится:
|
|||
03.12.2002, 17:56 |
|
|
start [/forum/topic.php?fid=47&fpage=713&tid=1856239]: |
0ms |
get settings: |
9ms |
get forum list: |
11ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
22ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
37ms |
get tp. blocked users: |
1ms |
others: | 9ms |
total: | 105ms |
0 / 0 |