写在前面
最近在做性能测试,需要用到数据批量处理操作,并发用户需要几百个,多则上千。
Mysql数据库在使用in查询时,可以使用field函数按照期望的顺序输出结果。
这样导出的结果就和查询的顺序一致,节省了核对的时间。
查询示例
SELECT
t.user_id,
t.login_id,
t.user_name,
t1.employee_id,
t1.legal_name,
t1.employee_code
FROM
t_sys_user t,
t_emp_employee t1
WHERE
t.user_id = t1.user_id
AND t1.employee_status = 2
AND t1.employee_code IN (
'10019301',
'10008623',
'10012733',
'10067039',
'10003992',
'10013087',
'10015103',
'10008848',
'10012205',
'10013190'
)
ORDER BY
FIELD(
t1.employee_code,
'10019301',
'10008623',
'10012733',
'10067039',
'10003992',
'10013087',
'10015103',
'10008848',
'10012205',
'10013190'
)
输出结果
查询数据输出效果如下所示:
温馨提示:欢迎加入软件测试学习交流QQ群:670250199