Mysql Concat two columns while searching with LIKE

前端 未结 3 2042
攒了一身酷
攒了一身酷 2021-01-07 02:57

I am trying to make a MySQL query where I filter the records based on the search text using LIKE keyword.

For example if the user searches for Illusion Softwar

相关标签:
3条回答
  • 2021-01-07 03:07

    you can try this also, this worked for me,

    $this->db->or_like('CONCAT(Contacts.FirstName,' ', Contacts.LastName)',$search);
    
    0 讨论(0)
  • 2021-01-07 03:16
    SELECT *,c.ID as CID 
    FROM Contacts c
    LEFT OUTER JOIN website_Data w ON c.ID=w.ContactID
    WHERE c.Email OR CONCAT_WS(' ',c.FirstName,c.LastName) LIKE '%Illusion Softwares%'
    ORDER BY c.Created DESC;
    
    0 讨论(0)
  • 2021-01-07 03:20

    Your query should be like this

    Select Contacts.*, Contacts.ID as CID 
    from Contacts 
    left join website_Data 
    on Contacts.ID = website_Data.ContactID 
    where CONCAT(Contacts.FirstName,' ', Contacts.LastName) LIKE '%Illusion Softwares%' 
    order by Contacts.`Created` DESC 
    
    0 讨论(0)
提交回复
热议问题