can someone please tell me what I am missing I have invested 4 hours and watch lots of article can't figure out why is showing return null
mysql mysql procedure is as follows.
create procedure proc_studymaterial_listing(
get_exam_id int(11)
)
begin
set @query1 = concat( "select c.content_type,
c.title,
c.status,
c.created_on,
c.pdf_is_downloadable,
a.content_id,
a.expiry_date,
exam_Name,
fun_subject_name(a.subject_id) as subject_name,
fun_subject_name(a.chapter_id) as chapter_name
from tbl_studymaterial_exam_chapter_map as a
join tbl_exam_master as b on a.exam_id= b.exam_ID
join tbl_studymaterial as c on c.id= a.content_id
where c.status=1 " );
if( get_exam_id = 0 )
then
set @exam_id = " and 1=1 ";
else
set @exam_id = concat( ' and b.exam_ID = " ', @get_exam_id , '"' );
end if;
SET @final_query = CONCAT ( @query1,@exam_id );
PREPARE stmt FROM @final_query ;
# select stmt;
# EXECUTE stmt;
# DEALLOCATE PREPARE stmt;
end;
PREPAREstatement withSELECT @final_query;and show the output. PS.get_exam_idisint(11)- why you quote it with dquote chars as it is a string?