monkey_boys
monkey_boys

Reputation: 7348

SOME in T-SQL: how to use it?

SELECT * FROM VNTREAT WHERE VN = SOME ('482')

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '482'.

Upvotes: 4

Views: 274

Answers (3)

OpenSource
OpenSource

Reputation: 2257

Try SELECT * FROM VNTREAT WHERE VN = SOME (Select '482')

Upvotes: 1

CMB
CMB

Reputation: 456

+1 Cool obscure SQL....Thanks curtisk...

From the links, it appears that SOME operates on series of returned values and can probably be expressed more understandable as 'AT LEAST ONE'... the usage looks similar to 'IN'...

Definitely cool...

Upvotes: 1

Eric
Eric

Reputation: 95153

The correct syntax for some is to use a subquery.

select * from vntreat where vn = some(select '482')

In the case of hard-coded values you want to use just = or in:

--Get the rows where vn is '482':
select * from vntreate where vn = '482'

--Get any of the rows that have vn equal to '480', '482', or '485'
select * from vntreat where vn in ('480', '482', '485')

Upvotes: 2

Related Questions