I was trying to create a mysql stored procedure function using mysql workbench, which will show result of join data of two tables on based on some conditions. I want to pass table names as parameter also.
My code is here:
CREATE PROCEDURE `Get_Texts`(IN wrd longtext, IN dbname longtext,
IN splitdbname longtext,
IN lang longtext)
BEGIN
SET @sql_ = CONCAT('SELECT * FROM ',dbname,' as ifxcd
INNER JOIN
',splitdbname,' as ifxsd
ON
ifxsd.Crawl_id = ifxcd.Id where ifxsd.Language = ',lang,'
AND ifxsd.Word Like ',wrd,'%
order by ifxsd.Percentage desc
limit 100');
PREPARE statement_ FROM @sql_;
EXECUTE statement_ ;
END
Call Function:
call Get_Texts('acc', emp_info, split_emp_txt , 'English(en)');
After calling the function I get an error
'Unknown column 'emp_info' in the field list
How can I overcome this and can see the desired output? Thanks in advance.
question from:
https://stackoverflow.com/questions/65937813/unknown-column-in-the-field-list-mysql-and-passing-dynamic-table-name-while 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…