MYSQL PROCEDURE FOR SEARCHING THE RELATED RESULTS IN THE TABLE:

In the below table i need to get the all the related records like science
for getting the results from multiple tables:
+----------+-----------+-----------------+------------+------------+
| courseId | cname     | cdesc           | sdate      | edate      |
+----------+-----------+-----------------+------------+------------+
|      301 | physics   | science         | 2013-01-03 | 2013-01-06 |
|      303 | chemistry | science         | 2013-01-09 | 2013-01-09 |
|      402 | afm       | finanace        | 2013-01-18 | 2013-01-25 |
|      403 | English   |  language       | 2013-01-17 | 2013-01-24 |
|      404 | Telugu    | spoken language | 2013-01-10 | 2013-01-22 |
+----------+-----------+-----------------+------------+------------+



use lportal;
 delimiter //
 create procedure pro_search143(IN sname varchar(20))
 begin

 SET @query = concat('select * 
                      from c_course 
                      where c_course.cdesc LIKE CONCAT(''%'',''',sname,''',''%'') 
                         OR c_course.cname LIKE CONCAT(''%'',''',sname,''',''%'');
                     ');

 PREPARE stmt FROM @query;
 EXECUTE stmt;

 end //

Search This Blog

All the rights are reserved to this blog is belongs to me only.. Powered by Blogger.