Ich benutze Mysql und ich habe eine schwierige Zeit versucht, die Ergebnisse von einer Update-Abfrage zu bekommen. Ich habe 2 Tische. Erste Tabelle loaddata_temp und zweiten Tabellenabschnitt company_categoryUpdate beitreten mit Case mysql
erste Tabelle loaddata_temp
|id_external|company_name |company_category_id|
-------------------------------------------------------------
| 1|iqballord |UD |
| 2|A Plus Lawn Care |PT |
| 3|A. L. Price |PMA |
| 4|A.J. August Fashion Wear |BUMN |
| 5|A+ Electronics |WARUNG |
| 6|A+ Investments |PT |
zweite Tabelle Company_category
|company_category_id|company_category_description|
--------------------|-----------------------------
| 3|PT |
| 5|UD |
| 6|PMA |
| 7|BUMN |
| 23|Koperasi |
habe ich diese Abfrage-Ergebnisse als
UPDATE loaddata_temp,company_category
SET loaddata_temp.company_category_id=
CASE
WHEN loaddata_temp.company_category_id = company_category.company_category_description
THEN company_category.company_category_id
ELSE 'error' END
zu bekommen, was ich expeted von oben Abfrage
|id_external|company_name |company_category_id|
-------------------------------------------------------------
| 1|iqballord |5 |
| 2|A Plus Lawn Care |3 |
| 3|A. L. Price |6 |
| 4|A.J. August Fashion Wear |7 |
| 5|A+ Electronics |error |
| 6|A+ Investments |3 |
aber was ich
|id_external|company_name |company_category_id|
-------------------------------------------------------------
| 1|iqballord |error |
| 2|A Plus Lawn Care |error |
| 3|A. L. Price |error |
| 4|A.J. August Fashion Wear |error |
| 5|A+ Electronics |error |
| 6|A+ Investments |3 |
warum verwenden Sie update ... anstelle von select ?! – Kunal
Ich muss überprüfen, wenn ich importierte mit lokalen Daten in Datei, die Zeile nicht mit company_category. Haben Sie einen Vorschlag oder den besten Weg, es zu tun? –