String comparison by SQL query

28 views
Skip to first unread message

Kasia K

unread,
Jul 30, 2022, 5:08:16 PM7/30/22
to cqengine-discuss
Hi guys!
Since few last days I'm wondering if there is a possibility to check by executing sql query whether string expression does not contain only a part of the another string instead of giving the full string value. I'm trying to exclude those elements from the collection.
For example I have:
String title = "abcdefg";
1) Select * from collection where (title not in ('cde') - I would like to filter out this element
2) Select * from collection where (title not in (' abcdefg') - It works but in my case user can fill in only a part of the string.

By using CQNParser query like: not(contains(element,value)) it works perfectly but in my case it would be much easier to use sql.

Cheers!
Kasia

Niall Gallagher

unread,
Jul 31, 2022, 4:57:17 AM7/31/22
to cqengine...@googlegroups.com
If I understand correctly, you could use SQL LIKE for this. Maybe try that and let me know if you have problems.

Best regards,
Niall

--
-- You received this message because you are subscribed to the "cqengine-discuss" group.
http://groups.google.com/group/cqengine-discuss
---
You received this message because you are subscribed to the Google Groups "cqengine-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cqengine-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cqengine-discuss/a72dc8c8-753c-45f1-a1e7-de03f0cfdcd2n%40googlegroups.com.

Kasia K

unread,
Jul 31, 2022, 6:53:22 AM7/31/22
to cqengine-discuss
What I need is to apply NOT LIKE query from sql.
As you suggested, like query won't work because it will return too many records.
I would expect for qiven values
title "abcde"
title "fghij"
receive only second value like during query
Select * from collection where title NOT LIKE '%cde%'

Niall Gallagher

unread,
Jul 31, 2022, 7:50:58 AM7/31/22
to cqengine...@googlegroups.com
Can you try:

NOT (title LIKE '%foo%')

I think the SQL parser will prefer that, rather than this:

title NOT LIKE '%foo%'




Kasia K

unread,
Jul 31, 2022, 8:52:02 AM7/31/22
to cqengine-discuss
Great, it works!
Thanks a lot Niall! 
Reply all
Reply to author
Forward
0 new messages