Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When chinese word in mysql where statement [duplicate]

Tags:

php

how to select 主页报修上广告

$sql = "SELECT text,pic FROM newstable where type='在线报修上广告' order by id desc limit 0,1";

but you may find the return value is null

But i try to use this

$sql = "SELECT text,pic FROM newstable where type=N'在线报修上广告' order by id desc limit 0,1";

there is N before '在线报修上广告' ------->>>>>but it works....what's the meaning of this 'N'!!

like image 812
000 Avatar asked Oct 31 '25 13:10

000


1 Answers

What is the meaning of the prefix N in T-SQL statements?

It#s declaring your varchar as nvarchar which is using a unicode encoding page. Otherwise it will be converted to the default encoding page of your database. Basically it's prefered to use only varchar when intended (like email addresses)

like image 69
Pwnstar Avatar answered Nov 02 '25 03:11

Pwnstar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!