Mysql sets a single variable and multiple variables, and a variable sets multiple values

1. Set one or more variables
set @emp_code='006', emp_name='Bugua';
select * from employee_task where emp_code=@emp_code and emp_name=@emp_name;

 2. Multiple values ​​for one variable

select * from bp_user_info where job_number in('ta001','ta002');

query by variable

set @emp_code ='ta001,ta002';
select * from bp_user_info where FIND_IN_SET(job_number,@emp_code);

 However, it should be noted that the query through the FIND_IN_SET function cannot go through the index, so the query speed will be slower

Guess you like

Origin blog.csdn.net/bugua3542/article/details/121683994