Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select

Author  Topic 

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-11-08 : 09:15:28
I have a scatered amount of programids I want to select in one query. but the programids are not in sequence. here is the example query.

SELECT table1.*
FROM table1
Where coverageid = 11 and programid = 1823 and pcmax = 8 and limitmax = 1000


but I want to select these specific programids all at once. Thanks for the help.

1823, 1826, 1829, 1832, 1835, 1838, 1841, 1844, 1847, 1850, 1853, 1856, 1859, 1862, 1865, 1868, 1871, 1874, 1877, 1880, 1883, 1886, 1889, 1892, 1895, 1898, 1901, 1904, 1907, 1910


Best
GG

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-11-08 : 09:28:02
You can do this

SELECT table1.*
FROM table1
Where coverageid = 11 and pcmax = 8 and limitmax = 1000
and programid IN
(1823, 1826, 1829, 1832, 1835, 1838, 1841, 1844, 1847, 1850, 1853, 1856, 1859, 1862, 1865, 1868, 1871, 1874, 1877, 1880, 1883, 1886, 1889, 1892, 1895, 1898, 1901, 1904, 1907, 1910
)


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-11-08 : 09:28:52
Great! thanks for the help.
Go to Top of Page
   

- Advertisement -