简化下。
表:create table tt(ID int,Name varchar(20));
数据:insert tt values(1,'a');select 1 from $t where ID =  1 and  'ca' like '%'+Name;
执行后,提示:
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+Name' at line 1
(0 ms taken)
而在Sql Server里面可以运行,请问在mysql应该怎么改?

解决方案 »

  1.   

    你要达到什么目的?SQL语句有问题
      

  2.   

    select 1 from $t where ID =  1 and  name like '%ca%'
      

  3.   

    是这样的,是'ca'这个字符串包括name里面的'a'.
    而不是name like '%ca%'
      

  4.   

    是'ca'这个字符串包括name里面的'a'.
    举个例子
    select 1 from $t where ID =  1 and instr('ca',name)>0
      

  5.   

    谢谢wwwwa.再请教下,
    select 1 from $t where 1=2;
    为什么在SqlYog下会返回结果1?
      

  6.   

    1是字段名,1=2为FALSE,没有记录
      

  7.   

    那为什么会在SqlYog下确有记录返回呢?
      

  8.   

    已经说过,不是记录,你试试
    select 1 from $t where not 1=2;