m_mlynek
asked on
php+mysql+concat
Im having a problem with a search function. What i want is to put multiple datafields from a table into a variable wich i, in the sql can search for with LIKE '%search_str%'
So far i have:
SELECT CONCAT(firstname, ' ', lastname) as full_name FROM tablename WHERE full_name LIKE '%search_str%'
It seams like i cant search for the concated field full_name. Any way to do this? Or is there another way to collect different datafields int one variable 'fictiv field' i can search for? This is the simplyfied sql to show what i mean, i have many other records taken out with the same criterias.
So far i have:
SELECT CONCAT(firstname, ' ', lastname) as full_name FROM tablename WHERE full_name LIKE '%search_str%'
It seams like i cant search for the concated field full_name. Any way to do this? Or is there another way to collect different datafields int one variable 'fictiv field' i can search for? This is the simplyfied sql to show what i mean, i have many other records taken out with the same criterias.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
//DB connections
$search_str = "somename or lastname" ;
$query ="SELECT concat(firstname,lastname)
$result = mysql_query($query) ;
while($row = mysql_fetch_object($result
echo $row->m ;
}