0

こんにちは、私はこれが多くのスレッドでここで回答されていることを知っていますが、クエリのエラーが何であるかを理解できません. 「オペランドには 1 列を含める必要があります」というエラーが表示されます。私がここで構築しているクエリのモンスターのように見えます。助けていただければ幸いです。

SELECT u.* FROM (
(SELECT fx_users.id, CONCAT_WS(' ', last_name, first_name) as matched_field, 'person' as type 
    FROM fx_users 
    LEFT JOIN fx_profiles ON fx_profiles.user_id = fx_users.id 
    WHERE (fx_profiles.first_name, fx_profiles.last_name, fx_profiles.research_area LIKE '%a%' 
    OR fx_profiles.bio LIKE '%a%' 
    OR fx_profiles.institution LIKE '%a%' 
    OR fx_profiles.faculty LIKE '%a%' 
    OR fx_profiles.faculty_position LIKE '%a%' 
    OR fx_profiles.department LIKE '%a%' 
    OR fx_profiles.website LIKE '%a%' 
    OR fx_profiles.country LIKE '%a%' 
    OR fx_profiles.city LIKE '%a%' 
    OR fx_profiles.address LIKE '%a%' 
    OR fx_profiles.zip_code LIKE '%a%' 
    OR fx_profiles.keywords LIKE '%a%' ) 
) 
UNION (SELECT fx_publications.publication_id, fx_publications.title as matched_field, 'publication' as type 
    FROM fx_publications 
    WHERE ( publications.authors LIKE '%a%' 
    OR publications.year LIKE '%a%' 
    OR publications.title LIKE '%a%' 
    OR publications.reference LIKE '%a%' ) 
) 
UNION (SELECT fx_projects.project_id, fx_projects.title as matched_field, 'project' as type 
    FROM fx_projects 
    WHERE ( projects.title LIKE '%a%' 
    OR projects.description LIKE '%a%' ) 
)
) AS u 
ORDER BY id DESC 
LIMIT 0, 20

どんな助けでも大歓迎です。PS: これは私の Codeigniter モデルのコードの一部です。

4

1 に答える 1

2

この行は意味がありません:

WHERE (fx_profiles.first_name, fx_profiles.last_name, fx_profiles.research_area LIKE '%a%' 

次のように変更する必要があります。

WHERE (fx_profiles.first_name LIKE '%a%' or
       fx_profiles.last_name  LIKE '%a%' or
       fx_profiles.research_area LIKE '%a%' 
        . . .
于 2014-07-18T02:14:55.673 に答える