Normal Syntax:
Copy codeThe Code is as follows:
Select * from table_name t where t. field1 in (1, 2, 3, 4 ,...);
When the list in the write stored procedure in is substituted with an input parameter, the following method is required:
The find_in_set function is mainly used.
Copy codeThe Code is as follows:
Select * from table_name t where find_in_set (t. field1, '1, 2, 3, 4 ');
Of course, you can also be stupid, that is, assembling strings and then executing:
Copy codeThe Code is as follows:
Drop procedure if exists photography. Proc_Test;
Create procedure photography. 'proc _ test' (param1 varchar (1000 ))
BEGIN
Set @ id = param1;
Set @ sel = 'select * from access_record t where t. ID in (';
Set @ sel_2 = ')';
Set @ sentence = concat (@ sel, @ id, @ sel_2); -- connection string to generate the SQL statement to be executed
Prepare stmt from @ sentence; -- precompile and release it. "Stmt" precompiled variable name,
Execute stmt; -- execute an SQL statement
Deallocate prepare stmt; -- release resources
END;