vulkan vulkan - 1 year ago 48
SQL Question

How to search with LIKE in columns merged with AS

I merged two column with AS , now I want to search data inside them with LIKE. How can i do that
*I using PHP

Php :

$sql = "SELECT CONCAT (name , ' ' , surname) AS full FROM person ";
$query = mysqli_query($con,$sql);
echo "<p>$row[full]</p>";
echo mysqli_error($con);

Answer Source

I think you could try like this - using the having clause rather than where

select concat( field1, field2 ) as 'alias'
from `table`
having `alias` like '%word%'

or, in your case:

SELECT CONCAT (`name` , ' ' , `surname`) AS 'full'  FROM `person`
having `full` like '%word%';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download