I want to implode a query result using "," inside my mysql stored procedure. How can I do that?
For example,
CREATE DEFINER=`root`@`%` PROCEDURE mysp()
BEGIN
DROP TABLE IF EXISTS temp;
CREATE TABLE temp (ids INT(11) , typeid INT(11));
INSERT INTO temp SELECT id,typeid FROM table_mine1 ..etc
INSERT INTO temp SELECT id,typeid FROM table_mine2 ..etc
After this I want to fetch all “ids” from temp table and make it as comma separated.
Because I need to write one another query like this
DELETE FROM main_table WHERE ids NOT IN (comma separated ids of temp table.)
How to implode ids of my temp table using comma?
Have a look at the GROUP_CONCAT function?
something like: