Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
jwalsh
- Forum Contributor
- Posts: 202
- Joined: Sat Jan 03, 2004 4:55 pm
- Location: Cleveland, OH
Post
by jwalsh »
Hi,
Is there a way using SQL to query WHERE a keyword is LIKE 2 fields combined?
ex.
SELECT * FROM testtable WHERE 'mysearch' LIKE '%(fielda CONCANTENATED WITH fieldb)%'
-
timvw
- DevNet Master
- Posts: 4897
- Joined: Mon Jan 19, 2004 11:11 pm
- Location: Leuven, Belgium
Post
by timvw »
Code: Select all
SELECT *
FROM table
WHERE CONCAT(name, ' ', surname) LIKE 'Van Wassenhove T%'
-
jwalsh
- Forum Contributor
- Posts: 202
- Joined: Sat Jan 03, 2004 4:55 pm
- Location: Cleveland, OH
Post
by jwalsh »
Awesome! haven't tried it yet, but knowing Timbo, it will work like a charm.
Thanks! Didn't know about CONCAT