我的疑问是
SELECT *
FROM `wp_patient_bill`
WHERE `bill_code` !=''
AND `is_billed` = 'Y'
AND `charged` = 'N'
AND `id` IN (97,419,631,632,633,422,635,421,35,799,60,423)
我希望记录数组将根据我的列表进行排序,即ID
‘97,419,631,632,633,422,635,421,35,799,60,423’
.我正在使用PHP.请建议我优化的方式来做到这一点.
解决方法:
SELECT *
FROM `wp_patient_bill`
WHERE `bill_code` !=''
AND `is_billed` = 'Y'
AND `charged` = 'N'
AND `id` IN (97,419,631,632,633,422,635,421,35,799,60,423)
ORDER BY FIELD(`id`,97,419,631,632,633,422,635,421,35,799,60,423)
参考:SQL order by sequence of IN values in query
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。