반응형
LIKE 키워드를 사용하여 검색 텍스트를 기반으로 레코드를 필터링하는 MySQL 쿼리를 만들려고합니다.
예를 들어 사용자가 Illusion Softwares
를 검색하는 경우 Illusion
은 이름이고 Softwares
는 성이므로 쿼리는 FirstName, LastName 열을 검색해야합니다. 둘 다 연결하고 검색하십시오.
지금까지 시도했지만 CONCAT
에서는 작동하지 않습니다.
Select Contacts.*, Contacts.ID as CID from Contacts left join
website_Data on Contacts.ID = website_Data.ContactID where
Contacts.`FirstName` LIKE '%Illusion Softwares%' or
Contacts.`LastName` LIKE '%Illusion Softwares%' or
concat(Contacts.FirstName, ' ', Contacts.LastName)
LIKE '%Illusion Softwares%'
or Contacts.Email LIKE '%Illusion Softwares%'
order by Contacts.`Created` DESC
내가 무엇을 놓치고 있습니까? 제발 도와주세요.
해결 방법
검색어는 다음과 같아야합니다.
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
참조 페이지 https://stackoverflow.com/questions/32177797
반응형
'MySql' 카테고리의 다른 글
MySQL mysql 쿼리의 성능을 확인하는 방법은 무엇입니까? (0) | 2020.11.18 |
---|---|
MySQL How to call a stored procedure using select statement in mysql (0) | 2020.11.18 |
MySQL PHP에서 문의 양식 7 양식 ID 받기 (0) | 2020.11.18 |
MySQL 가변 크기 변수 목록이있는 MySQL Prepared 문 (0) | 2020.11.18 |
MySQL pyodbc는 모든 형식의 명명 된 매개 변수를 지원합니까? (0) | 2020.11.18 |
댓글