Search code examples
mysqlsearchjoininner-joinsql-like

Search multiple queries oninner join table


Attached image is the inner join table. I want to make a search on the inner join table, between Title, Description and also the companyName. I not sure what is wrong with the query and please advise.

The results of table i'm searching on

SELECT campaign.name AS campaignTitle, campaign.desc AS campaignDesc, 
users.name AS companyName
FROM campaign
INNER JOIN users
ON campaign.userId=users.id
WHERE campaign.name like '%"Mia"%'
OR campaign.desc like '%"dolo"%'
OR users.name like '%"iT"%'

I'm newbie in doing the search function. Is there any more effective method to performs such a search? Please advise. Thanks

Update

The result returns nothing from the query above


Solution

  • Try:

    SELECT campaign.name AS campaignTitle, campaign.desc AS campaignDesc, 
    users.name AS companyName
    FROM campaign
    INNER JOIN users
    ON campaign.userId=users.id
    WHERE campaign.name like '%Mia%'
    OR campaign.desc like '%dolo%'
    OR users.name like '%iT%'
    

    Deleting double quotes in:

    ...like '%"Mia"%' ...