I have a table that has a column firstName
, of type NVARCHAR
. I'm writing a query to search by partial first name. My query looks like this:
$params[':firstName'] = "%วุฒิหิรัญทิ%";
$query = "SELECT * FROM users WHERE firstName LIKE :firstName";
$matches = $this-db->fetchAll($query, $params);
This doesn't work, and I've read that in MSSQL I need to use N
to search Unicode characters. How do I accomplish this in a prepared statement? I tried replacing :firstName
with N:firstName
and it did not work.
EDIT: This solution works for characters in the Latin 1 character set. It does not work for characters outside that set. For special characters, I can run a query directly such as SELECT * FROM users WHERE firstName LIKE N'%วุฒิหิรัญท%'
and it works fine, but I can't get it to work with prepared statements.