Page 1 of 1
Pattern Searching in UserDefined Column name
Posted: Wed Oct 20, 2004 10:29 pm
by anjanesh
Any workaround for this ?
Code: Select all
SELECT *,CONCAT(FirstName,' ',MiddleName,' ',LastName) AS FullName FROM People WHERE FullName LIKE '%something%'
Thanks
Posted: Wed Oct 20, 2004 10:34 pm
by feyd
can you explain a bit more?
Posted: Wed Oct 20, 2004 10:41 pm
by anjanesh
I want to search for
something in FullName - which is FirstName, MiddleName and LastName combined. But it wont work. Instead I've to to do :
Code: Select all
FirstName LIKE %something% OR MiddleNameName LIKE %something% OR LastName LIKE %something%
I was hoping to have it done easier by just giving
FullName
Posted: Wed Oct 20, 2004 10:48 pm
by feyd
maybe...
Code: Select all
SELECT * FROM table WHERE CONCAT_WS(' ', FirstName, MiddleName, LastName) LIKE '%something%'
Posted: Wed Oct 20, 2004 10:59 pm
by anjanesh
Yes that works - but I need somehow to have the user defined column for that query FullName to be searched. Im using this in a basic search engine of mine.
Posted: Wed Oct 20, 2004 11:04 pm
by feyd
you can create the column seperately..