How can I construct a query like this ?

Posts   
 
    
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 13-Jul-2011 15:23:42   

Query

SELECT r1.key,r1.value  FROM xf_resources r1
inner join xf_resources r2 on r1.TYPE = r2.TYPE
WHERE r1.culture = 'sk' AND r1.KEY = 'test';

Culture and Key are PK columns.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Jul-2011 15:53:35   

This query doesn't make sense.

What the purpose of joining to the same table, when it's not used outside of the join? If you run this query in SQL Server will it bring different results than when omitting the join.

I think the only difference is that the query you have posted might introduce duplicate records.

methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 13-Jul-2011 16:43:15   

I'd like to perform a select which would select also all other records with the same Type as the record with Culture = 'sk' and Key = 'test'

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Jul-2011 17:03:16   

Please re-formulate the SQL query and make sure it returns the results that you want and re-post it here, so we can help you implement it in LLBLGen code.

methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 15-Jul-2011 11:43:55   

The query works fine. The returned result is what I need. But this query can be rewritten to this

SELECT  r1.key,r1.value FROM xf_resources r WHERE r.type =
(SELECT type FROM xf_resources s  where s.culture= 'sk' and s.key= 'test')

I have searched the doc under the expressions chapter, but there was only an example with a scalar query.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Jul-2011 12:15:20   

WHERE r.type = (SELECT type FROM xf_resources s where s.culture= 'sk' and s.key= 'test')

For the above part you need to use a FieldCompareSetPredicate.