This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Queries REGEXP search

Tags: None
(comma "," separated)
lamomej
Registered Member
Posts
2
Karma
0

Queries REGEXP search

Tue Apr 16, 2019 12:33 pm
Hello,

I'm new on KEXI and SQL.

I want to make a match in a query.
I have thise query, that work very well :
SELECT Column_1, Column_2, Column_3, Column_4, Column_5, Column_7 FROM ipsite WHERE Column_4 = 'Computer12'

Now, I want all record with column_4 begining by 'Computer'.
I think the best way is a REGEXP. So I try to modify SQL request with some internet help :
WHERE Column_4 = 'Computer.*'
WHERE Column_4 REGEXP 'Computer.*'
WHERE regexp_like(Column_4,'Computer.*')
WHERE RLIKE(Column_4 , 'Computer.*' )
etc.
But nothing works.
More generally, I test functions in https://community.kde.org/Kexi/Plugins/ ... _Functions and some works (random, upper, length) and some don't work (count, sum...). How to know which ones work ?

So my question :
How to select all 'Computer.*' field ?

Thnk
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS

Re: Queries REGEXP search  Topic is solved

Tue Apr 16, 2019 12:40 pm
Hi Lamomej
Please google for "sqlite like", the LIKE operator is the way to go.

So e.g. instead WHERE Column_4 = 'Computer.*'

write

WHERE Column_4 LIKE 'Computer%'

(I am assuming .* is the regular expression, not a dot character and a wild card; please note, the LIKE operator is more like a wildcard, so it's limited)

We really shall add support for a REGEXP operator since even Sqlite supports it. Feel free to report a wish on bugs.kde.org. As always it's not a matter of adding a simple call - we need to check diferences between all three db engines we officially support, and possibly remove differences.


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help
lamomej
Registered Member
Posts
2
Karma
0

Re: Queries REGEXP search

Thu Apr 18, 2019 6:48 am
Thank you, it's work. It's clearly a very limited REGEXP...

Maybe you can add a verbatim escape for SQL requests, like an advanced mode. In charge to user to use it with intelligence (like LateX macro in Lyx, compiler option in codeblock or assembler code in C source).
User avatar
jstaniek
Moderator
Posts
1027
Karma
2
OS

Re: Queries REGEXP search

Sat May 25, 2019 6:52 pm
lamomej wrote:Maybe you can add a verbatim escape for SQL requests, like an advanced mode. In charge to user to use it with intelligence (like LateX macro in Lyx, compiler option in codeblock or assembler code in C source).


Agreed, that's always good too have feature. It's a wish reported at https://bugs.kde.org/show_bug.cgi?id=298149, feel free to vote :)


Best regards,
Jarosław Staniek
• Qt Certified Specialist
KEXI - Open Source Visual DB Apps Builder
• Request a feature or fix for KEXI here
May I help you? Please mention your app's version and OS when asking for help


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]