Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z delete, myqsl
motorolka24
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 21.04.2007

Ostrzeżenie: (0%)
-----


Witam. Mam problem z deletem. mam takie tabele

kategoria
----------
id

kategoriemarek
----------------
id
kategoriaid
markaid

marka
-------
id

dane
------
id
markaid


  1. DELETE FROM dane WHERE dane.id IN (SELECT dane.id
  2. FROM dane, marka, kategoriemarek, kategoria WHERE kategoria.id=1 AND kategoria.id=kategoriemarek.kategoriaid AND kategoriemarek.markaid=marka.id AND marka.id=dane.markaid);


Chce usunac wszystkie dane ktore sa odpowiednie dla kategorii =1

W mysql wyskakkuje mi taki blad: ERROR 1093 (HY000): You can't specify target table 'dane' for update in
FROM clause


Czy ktos wie co jest zle? Prosze o odpowiedz
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




jak komunikat glosi, nie mozesz w podzapytaniu szukac po tabeli, z ktorej wyzej kasujesz. To co ty chcesz zrobic mysle ze powinno ladnie pojsc przy uzyciu using
http://dev.mysql.com/doc/refman/5.0/en/delete.html
Cytat
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]

Cytat
DELETE FROM t1, t2 USING t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id;

These statements use all three tables when searching for rows to delete, but delete matching rows only from tables t1 and t2.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 00:47