Saturday, 31 August 2013

mysql procedure not working for searching 2 column values in the table?

mysql procedure not working for searching 2 column values in the table?

i have written the query like this:
select * from c_course where c_course.cdesc LIKE CONCAT('%',"science",'%')
OR c_course.cname LIKE CONCAT('%',"science",'%');
cid cname cdesc sdate edate
'301', 'physics', 'science', '2013-01-03', '2013-01-06'
'303', 'chemistry', 'science', '2013-01-09', '2013-01-09'
'501', 'science', 'natural science', '2013-01-31', '2013-01-09'
its working properly. same i have written using stored procedure like this:
use lportal;
delimiter //
create procedure pro_search143(IN sname varchar(20))
begin
SET @c = CONCAT('"',sname,'"');
select * from c_course where
c_course.cdesc LIKE CONCAT('%',c,'%')
OR
c_course.cname LIKE CONCAT('%',c,'%');
end
//
its executing but while calling the procedure it showing the error like this:
CALL pro_search143("science"); unknown column in c where clause.
can any one modify my code and give solution?

No comments:

Post a Comment