Nisar
Nisar

Reputation: 6038

string concat in mysql

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 ;

error

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 '+ '%' ; end' at line 12

Upvotes: 0

Views: 99

Answers (2)

ravnur
ravnur

Reputation: 2852

replace where condition with:

where productName like CONCAT(p_productName, '%')

Upvotes: 1

gbejic
gbejic

Reputation: 302

Maybe you can do it with CONCAT() function

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

Upvotes: 1

Related Questions