mysql中的字符串连接

时间:2013-12-11 08:12:33

标签: mysql sql

delimiter //
create procedure ProductViewAllByName(p_productName longtext)
begin
select  productId as 'Product Code',
        productName as 'Name',
        productGroupId as 'Group ID',
        manufactureId as 'Manufacture ID',
        stockMinimunLevel as 'Stock Minimum Level',
        stockMaximimLevel as 'Stock Maximum Level',
        description as 'Description',
        unitId as 'Unit ID'
        FROM tbl_Product
where productName like p_productName+'%' ;
end //
delimiter ;

错误

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在'+'%'附近使用正确的语法;在第12行结束

2 个答案:

答案 0 :(得分:1)

也许你可以用CONCAT()函数

来做
where productName like CONCAT(p_productName , '%');

答案 1 :(得分:1)

用以下内容替换where条件:

where productName like CONCAT(p_productName, '%')