in-function

SQL Server using wildcard within IN

十年热恋 提交于 2019-11-28 05:16:39
Since I believe this should be a basic question I know this question has probably been asked, but I am unable to find it. I'm probably about to earn my Peer Pressure badge, but I'll ask anyway: Is there a way in SQL Server that I am not aware of for using the wildcard character % when using IN. I realize that I can use OR's like: select * from jobdetails where job_no like '0711%' or job_no like '0712%' and in some cases I can use a subquery like: select * from jobdetails where job_no in (select job_no from jobs where job_id = 39) but I'm looking to do something like the following: select *

MySQL ORDER BY IN()

旧街凉风 提交于 2019-11-26 21:54:59
I have a PHP array with numbers of ID's in it. These numbers are already ordered. Now i would like to get my result via the IN() method, to get all of the ID's. However, these ID's should be ordered like in the IN method. For example: IN(4,7,3,8,9) Should give a result like: 4 - Article 4 7 - Article 7 3 - Article 3 8 - Article 8 9 - Article 9 Any suggestions? Maybe there is a function to do this? Thanks! Alex Martelli I think you may be looking for function FIELD -- while normally thought of as a string function, it works fine for numbers, too! ORDER BY FIELD(field_name, 3,2,5,7,8,1) You

SQL Server using wildcard within IN

雨燕双飞 提交于 2019-11-26 19:45:32
问题 Since I believe this should be a basic question I know this question has probably been asked, but I am unable to find it. I'm probably about to earn my Peer Pressure badge, but I'll ask anyway: Is there a way in SQL Server that I am not aware of for using the wildcard character % when using IN. I realize that I can use OR's like: select * from jobdetails where job_no like '0711%' or job_no like '0712%' and in some cases I can use a subquery like: select * from jobdetails where job_no in

MySQL ORDER BY IN()

随声附和 提交于 2019-11-26 08:05:24
问题 I have a PHP array with numbers of ID\'s in it. These numbers are already ordered. Now i would like to get my result via the IN() method, to get all of the ID\'s. However, these ID\'s should be ordered like in the IN method. For example: IN(4,7,3,8,9) Should give a result like: 4 - Article 4 7 - Article 7 3 - Article 3 8 - Article 8 9 - Article 9 Any suggestions? Maybe there is a function to do this? Thanks! 回答1: I think you may be looking for function FIELD -- while normally thought of as a