July 22, 2015 at 1:16 pm
Hi,
This should be a really simple, straight forward query, but apparently it's not. The error I get is "Invalid column name 'A'. I've put it in quotes and not in quotes and I left spaces around the equal sign and I've eliminated them. Can anyone tell me what's wrong with the SELECT statement below?
SELECT * from firms WHERE firm_id= 100002
AND active_firm = 1 AND firm_id != 100092
AND trust_id = A;
Thanks,
Rob
July 22, 2015 at 1:19 pm
Because it needs single quotes to identify strings. Most (or all) languages need quotes to identify strings, so there shouldn't be a big surprise. Without quotes, there would be no way to know if it's a column name or a string.
SELECT * from firms WHERE firm_id= 100002
AND active_firm = 1 AND firm_id != 100092
AND trust_id = 'A';
July 22, 2015 at 1:24 pm
That was it. Thanks!!!!
July 22, 2015 at 1:33 pm
Are you seriously asking? Or, is it a comment on your own answer? No, I don't take any code off the internet without testing it. It's been a slightly over a year and yes, I forgot that I need to single quote strings.
~ Rob
July 22, 2015 at 2:21 pm
That's his signature... it's put on all of the posts automatically.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 22, 2015 at 2:39 pm
WayneS (7/22/2015)
That's his signature... it's put on all of the posts automatically.
It's not the first time an OP has shared his opinion about the signature. 🙂
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
July 23, 2015 at 12:33 pm
Alvin Ramard (7/22/2015)
WayneS (7/22/2015)
That's his signature... it's put on all of the posts automatically.It's not the first time an OP has shared his opinion about the signature. 🙂
I just edited my signature to reduce confusions. I'll hope that it works.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply