Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL错误,原因未知_Mysql_Left Join - Fatal编程技术网

MySQL错误,原因未知

MySQL错误,原因未知,mysql,left-join,Mysql,Left Join,我已经读了这个问题大约20分钟了,我看不出有什么问题 SELECT SQL_CALC_FOUND_ROWS addressbook_people.first_name, addressbook_people.last_name , addressbook_people.preferred_name , addressbook_companies3.name

我已经读了这个问题大约20分钟了,我看不出有什么问题

SELECT   SQL_CALC_FOUND_ROWS addressbook_people.first_name,
         addressbook_people.last_name                     ,
         addressbook_people.preferred_name                ,
         addressbook_companies3.name                      ,
         addressbook_people.url                           ,
         addressbook_groups5.name                         ,
         addressbook_people.telephone1                    ,
         addressbook_people.telephone2                    ,
         addressbook_people.telephone3                    ,
         addressbook_people.email1                        ,
         addressbook_people.email2                        ,
         addressbook_people.fax1                          ,
         addressbook_people.fax2                          ,
         root_countries13.name                            ,
         root_territories14.name                          ,
         root_cities15.name                               ,
         addressbook_people.address1                      ,
         addressbook_people.zip_postal1                   ,
         addressbook_people.po_box                        ,
         root_countries19.name                            ,
         root_territories20.name                          ,
         root_cities21.name                               ,
         addressbook_people.address2                      ,
         addressbook_people.zip_postal2
FROM     addressbook_people
WHERE    (
                  (
                           addressbook_people.first_name     LIKE '%a%'
                  OR       addressbook_people.last_name      LIKE '%a%'
                  OR       addressbook_people.preferred_name LIKE '%a%'
                  OR       addressbook_companies3.name       LIKE '%a%'
                  OR       addressbook_people.url            LIKE '%a%'
                  OR       addressbook_groups5.name          LIKE '%a%'
                  OR       addressbook_people.telephone1     LIKE '%a%'
                  OR       addressbook_people.telephone2     LIKE '%a%'
                  OR       addressbook_people.telephone3     LIKE '%a%'
                  OR       addressbook_people.email1         LIKE '%a%'
                  OR       addressbook_people.email2         LIKE '%a%'
                  OR       addressbook_people.fax1           LIKE '%a%'
                  OR       addressbook_people.fax2           LIKE '%a%'
                  OR       root_countries13.name             LIKE '%a%'
                  OR       root_territories14.name           LIKE '%a%'
                  OR       root_cities15.name                LIKE '%a%'
                  OR       addressbook_people.address1       LIKE '%a%'
                  OR       addressbook_people.zip_postal1    LIKE '%a%'
                  OR       addressbook_people.po_box         LIKE '%a%'
                  OR       root_countries19.name             LIKE '%a%'
                  OR       root_territories20.name           LIKE '%a%'
                  OR       root_cities21.name                LIKE '%a%'
                  OR       addressbook_people.address2       LIKE '%a%'
                  OR       addressbook_people.zip_postal2    LIKE '%a%'
                  )
         )
         LEFT JOIN addressbook_companies AS addressbook_companies3
         ON       addressbook_people.company_id = addressbook_companies3.id
         LEFT JOIN addressbook_groups AS addressbook_groups5
         ON       addressbook_people.group_id = addressbook_groups5.id
         LEFT JOIN root_countries AS root_countries13
         ON       addressbook_people.country1 = root_countries13.id
         LEFT JOIN root_territories AS root_territories14
         ON       addressbook_people.territory1 = root_territories14.id
         LEFT JOIN root_cities AS root_cities15
         ON       addressbook_people.city1 = root_cities15.id
         LEFT JOIN root_countries AS root_countries19
         ON       addressbook_people.country2 = root_countries19.id
         LEFT JOIN root_territories AS root_territories20
         ON       addressbook_people.territory2 = root_territories20.id
         LEFT JOIN root_cities AS root_cities21
         ON       addressbook_people.city2 = root_cities21.id
ORDER BY LTRIM(addressbook_people.url)DESC
LIMIT    0, 10
这是数据表过滤器的输出。所以忽略这个事实,我正在寻找像‘a’

我使用PHPMyAdmin,当通过Web管理控制台在查询中执行SQL时,我收到以下错误

1064-您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 在“左侧”附近,加入通讯簿公司,作为3上的通讯簿公司 第54行的地址


我已经检查了线路,这是我连接的开始。我看没什么问题。。有人能帮忙吗?我从来都不擅长SQL。

您需要在
WHERE
子句之前执行
JOIN
s,在web管理控制台中查询长度可能没有限制,是吗?这是一个相当长的查询。我想看看这个查询需要在有1.000.000行的表上执行多长时间,这并不算多:)实际上并没有那么糟糕。现在我有6000行,它在几分之一秒内执行。这是ajax结果过滤的一部分。我看到了很少的延迟,所以很短,我还没有实际测试它。还应该提到的是,这只是为了支持10000-20000行而开发的,而不是假设您只为固定数量的项目开发。你永远不知道这个代码将来会被广泛使用。@Hughes,是的,我在发布后就注意到了我的错误。只是想澄清一下:WHERE在连接之后,而不是之前。是的!我不知道!每天学习新的东西!现在很有魅力。谢谢