Ich bin ziemlich neu MySQL, aber hatte einige Erfolge bis zum Treffen dieser Roadblock. Jede Hilfe würde sehr geschätzt werden.# 1064 - Sie haben einen Fehler in Ihrer SQL-Syntax ... in der Nähe von
Ich versuche, Tabelle 1 basierend auf einer übereinstimmenden Spalte in Tabelle 2 zu aktualisieren. MySQL-Version ist 5.5. Hier ist die 2 Tabellen (Entschuldigung für die ähnlichen Tabelle/Spaltennamen, sollte die Spalte Benennung vorher geplant):
Tabelle 1 - Domains
+--------+------------------------------------------+----------------+-----------+
| ID | DomainKeyword | GoogleSearches | GoogleCPC |
+--------+------------------------------------------+----------------+-----------+
| 406499 | 1k commandments | NULL | NULL |
| 406500 | 1k feet deep | NULL | NULL |
| 406501 | 1 market square | NULL | NULL |
| 406502 | 1marketst 3012 | NULL | NULL |
| 406503 | 1 massive cashflow | NULL | NULL |
| 406504 | 1 min tv | NULL | NULL |
| 406505 | 1 minutes tv | NULL | NULL |
| 406506 | 1 minutes tv | NULL | NULL |
| 406507 | 1 money mentor | NULL | NULL |
| 406508 | 1 my bia2 music | NULL | NULL |
| 406509 | 1n4j8 | NULL | NULL |
Tabelle 2 - googlesearches
+------+----------------------------------+----------+-------+
| ID | Keyword | Searches | CPC |
+------+----------------------------------+----------+-------+
| 3330 | audio buss | 480 | 0.00 |
| 3331 | balls to poverty | 30 | 0.00 |
| 3332 | boa homes | 10 | 0.00 |
| 3333 | bath construction | 10 | 0.00 |
| 3334 | bread crumbs catering | 10 | 0.00 |
| 3335 | complete recruit | 90 | 0.00 |
| 3336 | all about carpets | 10 | 0.00 |
| 3337 | consulting world | 10 | 0.00 |
| 3338 | car insurance loans | 50 | 3.64 |
| 3339 | building experts | 50 | 0.00 |
| 3340 | boyfriend jealousy | 30 | 0.00 |
| 3341 | avid farm shop | 30 | 0.00 |
| 3342 | chic bridesmaid | 10 | 0.00 |
| 3343 | ad wholesale | 10 | 0.00 |
| 3344 | buy game card | 10 | 0.00 |
| 3345 | daily driving | 10 | 0.00 |
| 3346 | church farm cottage | 260 | 1.18 |
Hier ist der Befehl, es scheint, bestimmte Befehle, die ich mit einem 'FROM' ausführen, werfen den gleichen Fehler:
UPDATE dest
SET GoogleSearches = src.Searches,
GoogleCPC = src.CPC
FROM domains AS dest
INNER JOIN googlesearches AS src
ON dest.DomainKeyword = src.Keyword;
Der Fehler, den ich immer bin, wenn Sie den Befehl auszuführen versucht:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM domains AS dest INNER JOIN googlesearches AS src ON dest.DomainKeyword = ' at line 4
Wenn ich mich nicht täusche, eine MySQL- UPDATE' Abfrage mit mehreren Tabellen aussehen würde als folgt: 'UPDATE Domains, GoogleSuche SETS GoogleSearches = src.Searches, GoogleCPC = src.CPC WHERE Domains.DomainKeyword = googlesearches.Keyword;'. Ich werde dies zu einer Antwort bewegen, sollte es funktionieren. –
Update mit einem Join-Muster hat die 'SET' am Ende – Drew
Mögliche Duplikat von [Wie verwenden Sie Inner Join in Update-Anweisung In MYSQL] (http://StackOverflow.com/questions/8057565/how-to-use- inner-beitreten-in-update-statement-in-mysql) – Drew