有如下的表结构 及数据-- ----------------------------
-- Table structure for e_role
-- ----------------------------
CREATE TABLE `e_role` (
  
`uri` varchar(80) collate utf8_unicode_ci NOT NULL,
  
`version` int(11) NOT NULL,
  `flags` int(11) NOT NULL,
  
`name` varchar(255) collate utf8_unicode_ci default NULL,
  
`description` varchar(255) collate utf8_unicode_ci default NULL,
  
`enName` varchar(255) collate utf8_unicode_ci default NULL,
  `roleType` int(11) NOT NULL,
  
`fkDomain` varchar(80) collate utf8_unicode_ci default NULL,
 
PRIMARY KEY  (`uri`))
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;-- ----------------------------
-- Records 
-- ----------------------------
INSERT INTO `e_role` VALUES ('admin', '0', '0', '管理员', '管理员拥有很高的权限', 'admin', '0', '/');
这样的 SQL为什么不能执行select * from e_role where 'admin' like '%'+uri+'%';
同样的SQL在 MS SQL中是可以执行的谢谢!!

解决方案 »

  1.   

    mysq 版本如下:Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 17 to server version: 5.0.27-community-nt
      

  2.   

    select * from e_role where 'admin' like concat(''%',uri,'%'');
      

  3.   

    select * from e_role where 'admin' like concat('%',uri,'%');  这样能执行,,,因为这个SQL是用Hiberante生成的。。Hiberante 的HQL 自动翻译成了 ‘+’做关键字的
      

  4.   

    MSSQL字符串连接就是用的+号,而MYSQL是用CONCAT函数。
      

  5.   

    select * from e_role where 'admin' like concat( '%',uri,'%');
      

  6.   

    mysql 用CONCAT(SRT1,STR2...STRN)连接字符串