Is this possible?

Posts   
 
    
KristianP
User
Posts: 32
Joined: 23-Feb-2005
# Posted on: 14-May-2007 19:18:50   

I'm creating an un-typed list and I was wondering if the following is possible:

select id, (select top 1 address from address where customerid = id) as address where...

the part i am not sure of is the sub-query because i need to pull back only one address (main). thanks!

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 14-May-2007 22:46:53   

so long as address is 1 field you can use the ScalarQueryExpression() function in the help docs: LLBLGen Pro ->generated code -> field expressions and aggregates -> scalar query expressions.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-May-2007 09:32:24   

Hint: A ScalarQueryExpression automatically performs a TOP 1 on the resultset, so you can specify a query which actually doesn't return a single value: the generated SQL will make sure there'll be just one value returned by the scalar query so the containing SELECT statement won't fail at runtime.