Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Oct 20, 2004 10:29 pm
Any workaround for this ?
Code: Select all
SELECT *,CONCAT(FirstName,' ',MiddleName,' ',LastName) AS FullName FROM People WHERE FullName LIKE '%something%'
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 20, 2004 10:34 pm
can you explain a bit more?
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Oct 20, 2004 10:41 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 20, 2004 10:48 pm
maybe...
Code: Select all
SELECT * FROM table WHERE CONCAT_WS(' ', FirstName, MiddleName, LastName) LIKE '%something%'
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Oct 20, 2004 10:59 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 20, 2004 11:04 pm
you can create the column seperately..