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
 Trying to use the IN List

Author  Topic 

tranquilraven
Starting Member

19 Posts

Posted - 2012-06-08 : 11:13:16
But I keep getting an error saying Your SQL is invalid: An expression of non-boolean type specified in a context where a condition is expected, near 'Code'.


Huh? I really, really want to understand this. Can someone please help explain what I am doing wrong, here is the code:


SELECT ProductCode, ProductPrice, ProductWeight
FROM Products
Where Product Code IN (RP2000,RP600,RP800,RP1000,F2000C,F1500C,F1000C,F700C,F600C,SFS2000,SFS1000,SFS600,F400C,RP400);
ORDER BY ProductCode

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-06-08 : 11:14:58
Perhaps the values in your IN clause are actualy strings and need to be enclosed in single quotes?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-06-08 : 11:16:45
[code]
Where ProductCode IN ('RP2000', 'RP600', 'RP800', 'RP1000', 'F2000C', 'F1500C',
'F1000C', 'F700C', 'F600C', 'SFS2000', 'SFS1000', 'SFS600', 'F400C', 'RP400');
ORDER BY ProductCode
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

tranquilraven
Starting Member

19 Posts

Posted - 2012-06-08 : 11:17:00
Nope same error.


quote:
Originally posted by Lamprey

Perhaps the values in your IN clause are actualy strings and need to be enclosed in single quotes?

Go to Top of Page

tranquilraven
Starting Member

19 Posts

Posted - 2012-06-08 : 11:19:30
LOL. Thank you both, you were both right. I misspelled ProductCode and I needed the quotes. Bless you both.


quote:
Originally posted by khtan


Where ProductCode IN ('RP2000', 'RP600', 'RP800', 'RP1000', 'F2000C', 'F1500C',
'F1000C', 'F700C', 'F600C', 'SFS2000', 'SFS1000', 'SFS600', 'F400C', 'RP400');
ORDER BY ProductCode



KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page
   

- Advertisement -