使用析取範式:
SELECT c.companyID,
c.companyDescription, c.companyName, c.copmanyDrastiriotita,
c.companyVisible
FROM company c
WHERE (c.companyVisible = 1 AND c.companyName LIKE '%Keyword%')
OR (c.companyVisible = 1 AND c.companyDescription LIKE '%Keyword%')
OR (c.companyVisible = 1 AND c.copmanyDrastiriotita LIKE '%Keyword%')
使用原始運算符(c3
可能是VIEW
):
SELECT c2.companyID,
c2.companyDescription, c2.companyName, c2.copmanyDrastiriotita,
c2.companyVisible
FROM company c2, (
SELECT c1.companyID, c1.companyName AS text_to_search
FROM company c1
UNION
SELECT c.companyID, c.companyDescription AS text_to_search
FROM company c1
UNION
SELECT c1.companyID, c1.copmanyDrastiriotita AS text_to_search
FROM company c1
) AS c3 (companyID, text_to_search)
WHERE c2.companyVisible = 1
AND c3.text_to_search LIKE '%Keyword%'