(RESOLVED) Nested SELECT statements
Does anybody know if it is possible to share data between nested SQL statements. I.E.
Code:
SELECT SomeFields...,(SELECT SUM(OtherField) FROM table WHERE OtherFieldForiegnKey=SomeFieldPrimaryKey) FROM OTHERTable
So from the above OtherFieldID would match the ID of the record from the first table. I don't seem to be able to figure it out. Can anybody help?
Thanks,
-=XQ=-
Re: Nested SELECT statements
Quote:
Originally posted by -=XQ=-
Does anybody know if it is possible to share data between nested SQL statements. I.E.
Code:
SELECT SomeFields...,(SELECT SUM(OtherField) FROM table WHERE OtherFieldForiegnKey=SomeFieldPrimaryKey) FROM OTHERTable
So from the above OtherFieldID would match the ID of the record from the first table. I don't seem to be able to figure it out. Can anybody help?
Thanks,
-=XQ=-
you want to use a join statement for this
something like
Code:
Select table1.field1, table1.field2, table2.field1 from table1 inner join table2 on table1.UniqueID = table2.UniqueID
not sure if that syntax is 100% but its close...
what you shoudl do is build the query in ACCESS (thats what you are using right?) and then look at the code that it generates... you could then use that sql syntax in your VB app