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

1
  • use a splitter from this site and inner join to the result set is one way, assuming your "array" is a comma separated parameter you are passing in. Commented Jun 20, 2017 at 20:24

2 Answers 2

1

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

Phone in ('05763671278','05763271578','04763125578')
Sign up to request clarification or add additional context in comments.

Comments

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.

3 Comments

this give error Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '
Wow... duplicate answer for the win. Original.
@Theesisia can you look this : stackoverflow.com/questions/44682595/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.