When is the Chinese word in mysql where expression

how to choose 主页 报 修 上 广告

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

      

but you can find the return value is null

But I am trying 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 point of that 'N' !!

+3


source to share


1 answer


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



It # declares your varchar as nvarchar which uses the Unicode encoding page. Otherwise it will be converted to your database's default encoding page. Basically, he prefers to use only varchar if it's intended (like email addresses)

+2


source







All Articles