[mysql] nie mozna updejtowac tabeli bedacej zrodlem danych

0
> update accountinfo set typ='SERVER' where deviceid in (select BIOS.deviceid from BIOS,accountinfo where accountinfo.deviceid=bios.deviceid and SMODEL like 'Power%' and typ is null);

ERROR 1093 (HY000): You can't specify target table 'accountinfo' for update in FROM clause

co zrobic aby jednak accountinfo.typ dostalo swoja wartosc ? (oracl i mssql ponoc lyknalby ta skladnie)

0

Moze sprobuj cos takiego

update accountinfo set typ='SERVER' where deviceid in (select deviceid from BIOS where SMODEL like 'Power%') and typ is null

Nie jestem pewien czy mysle dobrze, ale takie cos powinno byc rownowazne temu powyzszemu.

pozdrawiam
johny

0

a SMODEL w której jest tabeli
a jeszcze lepiej podaj struktury

PS. stosuj tag code=sql

0
mysql> desc bios ;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| DEVICEID      | varchar(255) | NO   | PRI |         |       |
| SMANUFACTURER | varchar(255) | YES  |     | NULL    |       |
| SMODEL        | varchar(255) | YES  |     | NULL    |       |
| SSN           | varchar(255) | YES  | MUL | NULL    |       |
| TYPE          | varchar(255) | YES  |     | NULL    |       |
| BMANUFACTURER | varchar(255) | YES  |     | NULL    |       |
| BVERSION      | varchar(255) | YES  |     | NULL    |       |
| BDATE         | varchar(255) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
8 rows in set (0.03 sec)

mysql> desc accountinfo ;
+-------------------------+--------------+------+-----+---------+-------+
| Field                   | Type         | Null | Key | Default | Extra |
+-------------------------+--------------+------+-----+---------+-------+
| DEVICEID                | varchar(255) | NO   | PRI |         |       |
| TAG                     | varchar(255) | YES  | MUL | NA      |       |
| Dzial                   | varchar(255) | YES  |     | NULL    |       |
| Data_Zakupu             | date         | YES  |     | NULL    |       |
| Data_Gwarancji          | date         | YES  |     | NULL    |       |
| Numer_Faktury           | varchar(255) | YES  |     | NULL    |       |
| Numer_Srodka            | varchar(255) | YES  |     | NULL    |       |
| Firma_Serwisujaca       | varchar(255) | YES  |     | NULL    |       |
| Nr_Umowy_Serwisowej     | varchar(255) | YES  |     | NULL    |       |
| Roczny_Koszt_Serwisu    | int(11)      | YES  |     | NULL    |       |
| OPIS                    | varchar(255) | YES  |     | NULL    |       |
| Aplikacja               | varchar(255) | YES  |     | NULL    |       |
| Typ                     | varchar(255) | YES  |     | NULL    |       |
| Purchase_Price          | double       | YES  |     | NULL    |       |
| Yearly_Maintenance_Cost | double       | YES  |     | NULL    |       |
+-------------------------+--------------+------+-----+---------+-------+
0

zobacz coś takiego

UPDATE accountinfo, bios SET accountinfo.typ='SERVER' WHERE accountinfo.deviceid=bios.deviceid AND bios.SMODEL LIKE 'Power%' AND accountinfo.typ IS NULL;

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0