SQL "LIKE"
The wiki give some great examples of basic SQL to ECL code samples. What would be the ECL equivalent to SQL:
- Code: Select all
SELECT * FROM `table` WHERE `email` LIKE "%@gmail.com"
Last edited by househippo on Tue May 27, 2014 4:14 pm, edited 1 time in total.
- househippo
- Posts: 18
- Joined: Sun Nov 03, 2013 9:32 pm
There is a standard library function that you can use as a recordset filter to do this:
Cheers,
Dan
- Code: Select all
IMPORT Std;
DataRec := RECORD
STRING email;
END;
myTable := DATASET
(
[
{'[email protected]'},
{'[email protected]'},
{'[email protected]'}
],
DataRec
);
r := myTable(Std.Str.EndsWith(email, '@gmail.com'));
OUTPUT(r);
Cheers,
Dan
- DSC
- Community Advisory Board Member
- Posts: 571
- Joined: Tue Oct 18, 2011 4:45 pm
I just realized that my response was a little specific, focusing on testing the end of a string. Check out the REGEXFIND() built-in function. It would be used in a filter, like the Std.Str.EndsWith() above, and would provide SQL LIKE-like functionality (and more).
Cheers,
Dan
Cheers,
Dan
- DSC
- Community Advisory Board Member
- Posts: 571
- Joined: Tue Oct 18, 2011 4:45 pm
Dan thanks for the response.
Regular expression can be expensive process in terms of CPU and memory when the string are large.
Is there other tools to use besides REGEXFIND() on these large strings when they are MB or GB size?
EX.
Regular expression can be expensive process in terms of CPU and memory when the string are large.
Is there other tools to use besides REGEXFIND() on these large strings when they are MB or GB size?
EX.
- Code: Select all
Select * FROM `table` WHERE `html` LIKE "%iPad2%"
- househippo
- Posts: 18
- Joined: Sun Nov 03, 2013 9:32 pm
Std.Str.Contains() would be another candidate to check out. There are a few others in the string library that may meet your needs as well, such as WildMatch().
Cheers,
Dan
Cheers,
Dan
- DSC
- Community Advisory Board Member
- Posts: 571
- Joined: Tue Oct 18, 2011 4:45 pm
househippo,
This previous thread: http://hpccsystems.com/bb/viewtopic.php?f=8&t=1193&p=5185&hilit=+LIKE&sid=45bef542c61fec074e57dfc7f991132c&sid=45bef542c61fec074e57dfc7f991132c#p5185 also addresses the issue of how to do an SQL LIKE.
HTH,
Richard
This previous thread: http://hpccsystems.com/bb/viewtopic.php?f=8&t=1193&p=5185&hilit=+LIKE&sid=45bef542c61fec074e57dfc7f991132c&sid=45bef542c61fec074e57dfc7f991132c#p5185 also addresses the issue of how to do an SQL LIKE.
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest