#1064 - 您的SQL语法错误...在FROM附近

时间:2016-07-12 15:50:57

标签: mysql

我是一个非常新的MySQL,但在遇到这个障碍之前取得了一些成功。任何帮助将不胜感激。

我正在尝试根据表2中的匹配列更新表1.MySQL版本为5.5。这里有2个表(对于类似的表/列名称的道歉,应该预先计划列命名):

表1 - 域名

+--------+------------------------------------------+----------------+-----------+
| 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 |

表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 |

这是命令,似乎我使用' FROM'运行的某些命令。抛出同样的错误:

UPDATE dest
  SET GoogleSearches = src.Searches,
    GoogleCPC = src.CPC
FROM domains AS dest
INNER JOIN googlesearches AS src
ON dest.DomainKeyword = src.Keyword;

尝试运行命令时遇到的错误:

#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

2 个答案:

答案 0 :(得分:0)

试试这个: 反转你的查询...我认为它在mysql中比在sql server中相反:

UPDATE domains AS dest
INNER JOIN googlesearches AS src ON dest.DomainKeyword = src.Keyword
  SET dest.GoogleSearches = src.Searches,
   dest.GoogleCPC = src.CPC;

答案 1 :(得分:0)

试试这个

class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        #Original Solution
        num0 = -1
        num1 = -1
        num_map = dict(zip(nums, range(len(nums))))
        for key in nums:
            rem = target - key
            if rem not in num_map:
                continue
            else:
                num0 = num_map[key]
                num1 = num_map[rem]
        return [num0, num1]



sol = Solution()
test = sol.twoSum([3,2,4], 6)