Help with LLBLGen query

Posts   
 
    
p0_oq
User
Posts: 3
Joined: 20-Jun-2006
# Posted on: 20-Jun-2006 04:56:02   

I'm trying to form the code that represents the query with left join on a filtered table. Like this:

select * from tableA left join (select * from tableB where name='needed') as tableTemp on tableA.key = tableTemp.key where ...

Is it possible to convert to LLBLGen code or rewrite to query to achive the desired result? One thing i can think of is to run two separate queries and to perform the left join in my own code, but that's not the most desirable solution for me.

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Jun-2006 07:20:39   

Could this be written as :

select * from tableA left join tableB on tableA.key = tableB.key 
where where tableB.name='needed' AND...

?

p0_oq
User
Posts: 3
Joined: 20-Jun-2006
# Posted on: 20-Jun-2006 23:02:53   

I don't think they are the same. I wanted to filter first, then left join.

So for example:

TableA:

Key Value

1 value1 2 value2 3 value3

TableB:

Key Name

1 needed 2 not needed

My query will produce 3 lines, and your query will produce 2 lines.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 21-Jun-2006 17:07:45   

query is the same as:


select * from tableA left join tableB on tableA.key = tableB.key
AND name='needed'  
where ...

The AND clause can be added with the CustomFilter property of the EntityRelation. See "Custom filters for EntityRelations" in FIltering and sorting -> Advanced filtering.

Frans Bouma | Lead developer LLBLGen Pro
p0_oq
User
Posts: 3
Joined: 20-Jun-2006
# Posted on: 22-Jun-2006 01:28:26   

Awesome! Thanks Otis.