I'm trying to make a query using like in PHP and when I use one more than one word.
Only works if I only put one word.
In SQL Server the query works without errors .
<?php
function listaMatHistOS($conn, $equipamento){
$HistMatOS = array();
$where = [];
$where[] = "cliente.id = (select usuario.idCliente from usuario where usuario.login = '".usuarioLogado()."')";
if ($equipamento) {
$where[] = "material.nome like '%{$equipamento}%'";
}
$SQL = "select os.id as IdOS, os.dataHora, material.nome as equipamento, itemMaterial.nSerie, itemMaterial.patrimonio,
itemMaterial.rm, os.status
from os
inner join itemMaterial on
itemMaterial.id = os.id
inner join material on
material.id = itemMaterial.idMaterial
inner join cliente on
cliente.id = os.idCliente
where " . implode(' AND ', $where) ;
$resultado = sqlsrv_query($conn, $SQL);
while ($RelMatOS = sqlsrv_fetch_array($resultado, SQLSRV_FETCH_ASSOC)){;
array_push($HistMatOS, $RelMatOS);
}
echo $SQL;
return $HistMatOS;
}