I'm using the following query:
SELECT B.name AS BranchName,
(SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
a.name = "homecover") AS AddOn1,
(SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
a.name = "policyfee") AS AddOn2,
(SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
a.name = "legalprotection") AS AddOn3
FROM data_branchDetails B
I get the error 'Invalid Column Name 'homecover' - not sure why as this
is just a normal string expression?
Regards,
ChrisChris
Perhaps you need to use single quotations as
'blblbla'
"Chris Ashley" <chris.ashley2@.gmail.com> wrote in message
news:1131618544.125109.96910@.g43g2000cwa.googlegroups.com...
> I'm using the following query:
> SELECT B.name AS BranchName,
> (SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
> a.name = "homecover") AS AddOn1,
> (SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
> a.name = "policyfee") AS AddOn2,
> (SELECT a.cost from data_BranchAddOns a WHERE a.branchid = B.id AND
> a.name = "legalprotection") AS AddOn3
> FROM data_branchDetails B
> I get the error 'Invalid Column Name 'homecover' - not sure why as this
> is just a normal string expression?
> Regards,
> Chris
>|||Okay, please disregard. I'm an idiot and was using double quotes for
some reason :P
I think I've just been spending too much time with C# these past few
months and not enough with SQL.
Showing posts with label branchname. Show all posts
Showing posts with label branchname. Show all posts
Monday, March 12, 2012
Invalid Column Name in Subquery?
Subscribe to:
Posts (Atom)