0

I have phone in my arrays such

 string phones="05763671278,05763271578,04763125578"

How can I result of all phone in that array?(for this case there must be return 3 records)

SELECT * FROM Accounst where Phone in ('05763671278,05763271578,04763125578')

but it return null although this phone in table

user1688401
  • 1,811
  • 7
  • 40
  • 79
  • use a splitter [from this site](http://www.sqlservercentral.com/articles/Tally+Table/72993/) and inner join to the result set is one way, assuming your "array" is a comma separated parameter you are passing in. – S3S Jun 20 '17 at 20:24

2 Answers2

1

if phone is a string (varchar or char) you want:

Phone in ('05763671278','05763271578','04763125578')
benjamin moskovits
  • 5,073
  • 1
  • 11
  • 21
0

You are missing the quotations. Do it like this:

SELECT * FROM Accounst where Phone in ('05763671278','05763271578','04763125578')

It returns NULL because it looks for a phone number as:

'05763671278,05763271578,04763125578'

and obviously this is not a phone number.

TheEsnSiavashi
  • 1,234
  • 1
  • 13
  • 28