Ошибка MySQL, неизвестная причина - PullRequest
1 голос
/ 18 августа 2011

Я читаю этот запрос уже около 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

Это вывод моего фильтра для таблицы данных. Так что не обращайте внимания на тот факт, что я ищу "а"

Я использую PHPMyAdmin, при выполнении SQL в запросе через веб-консоль управления я получаю следующую ошибку

1064 - у вас ошибка в синтаксисе SQL; проверьте руководство, что

соответствует вашей версии сервера MySQL для правильного использования синтаксиса около 'LEFT JOIN addressbook_companies AS addressbook_companies3 ON адрес в строке 54

Я проверил линию, это начало моих соединений. Я не вижу проблемы .. Может кто-нибудь помочь? Я никогда не работал с SQL.

1 Ответ

3 голосов
/ 19 августа 2011

Вам нужно сделать JOIN с до WHERE пункта

...