exists

Posts   
 
    
vvv
User
Posts: 4
Joined: 27-Apr-2011
# Posted on: 27-Apr-2011 15:36:04   

Hi all,

Can someone please help me with this particular peace of sql code that i need to write in LLBL:

select * from myTable t where exists (select null from myOtherTable ot where t.nonKeyColumn = ot.nonKeyKolumn and t.nonKeyColumn2 = ot.nonKeyKolumn2 and t.nonKeyColumn3 = ot.nonKeyKolumn3)

I found some code samples on that matter, but none of those i could use directly, and I have hard time figuring it out myself.

Thanks in advance, V

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Apr-2011 15:53:25   

Isn't this exactly the same as a simple Join.

If you still want to use the Exists clause, then please check FieldCompareSetPredicate

vvv
User
Posts: 4
Joined: 27-Apr-2011
# Posted on: 27-Apr-2011 16:01:51   

Thank you for such a quick answer.

You are absolutely right, I didn't gave you exact query, in which where clause is quite a bit more complex then the one I posted.

I've already seen the link you've posted, but something bothered me, it looks like you have to name one column as first parameter, and I can not provide it, because key column is not of any importance to the query I intend to execute.

I would be grateful if you could provide me with code sample for the problem I described in first post.

Cheers, V

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Apr-2011 16:19:25   

Naming a column won't make a difference in the resultSet. As the Outer Selected Entity is the one which will be returned.

vvv
User
Posts: 4
Joined: 27-Apr-2011
# Posted on: 27-Apr-2011 16:36:10   

That's the one simple_smile

Works like charm now, thanks.

vvv
User
Posts: 4
Joined: 27-Apr-2011
# Posted on: 28-Apr-2011 14:59:38   

Guys,

I could use some more help on this one.

in FieldCompareSetPredicate i need to add predicate which checks if value of one field contains value of another ( both fields are of type string )

SQL code would be something like: ...AND field1 like field2 + '%'

Any ideas?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 28-Apr-2011 21:55:46   

You need to have a look at FieldExpressions http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/gencode_expressionsaggregates.htm#expressions which are designed expressly to do this sort of field manipulation and comparisons.

Matt