SQL query with IS LIKE clause - and user entry
-
- Posts: 9
- Joined: Fri Dec 09, 2022 4:06 am
SQL query with IS LIKE clause - and user entry
Hello,
I'm new to OO_Base so I may be barking up the wrong tree.
But I would like to create a form which has a search field in it.
I would type in a search string and it would initiate a search based on a pre-made query
That query would have one WHERE clause which will be an IS LIKE clause - the string of which the user must enter at run time.
So for example - I would be searching a column in a table where some text within that table IS LIKE whatever the user enters at run-time.
I think I'm headed in the correct path in accomplishing this.
If so - then what I would be asking here is the Query Syntax for the IS LIKE clause requiring user entry at run-time
Sincere thanks in advance!
I'm new to OO_Base so I may be barking up the wrong tree.
But I would like to create a form which has a search field in it.
I would type in a search string and it would initiate a search based on a pre-made query
That query would have one WHERE clause which will be an IS LIKE clause - the string of which the user must enter at run time.
So for example - I would be searching a column in a table where some text within that table IS LIKE whatever the user enters at run-time.
I think I'm headed in the correct path in accomplishing this.
If so - then what I would be asking here is the Query Syntax for the IS LIKE clause requiring user entry at run-time
Sincere thanks in advance!
OpenOffice Version: 6.2.8.2 - on Linux Lite
Re: SQL query with IS LIKE clause - and user entry
Did you look at [Solved] Way to pass parameters into queries?
You don't mention which database you are using - Base is not a database but an interface to a number of database applications - but I don't know of any variant of SQL that has IS LIKE; there is LIKE however.
You don't mention which database you are using - Base is not a database but an interface to a number of database applications - but I don't know of any variant of SQL that has IS LIKE; there is LIKE however.
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.-
- Posts: 9
- Joined: Fri Dec 09, 2022 4:06 am
Re: SQL query with IS LIKE clause - and user entry
Sorry
That was my mistake
The DB is one created within OO_Base
So LIKE would be correct
Thanks
That was my mistake
The DB is one created within OO_Base
So LIKE would be correct
Thanks
OpenOffice Version: 6.2.8.2 - on Linux Lite
Re: SQL query with IS LIKE clause - and user entry
Hello,
two samples:
1. with parameter
2. using an extra filtertable
Info:
means, you have only to type the beginning of a word to match all words that begin like what you typed in.
two samples:
1. with parameter
Code: Select all
... WHERE ( LOWER ( "Name" ) LIKE LOWER ( :qName || '%' ) OR :qNameIS NULL )
Code: Select all
... WHERE ( LOWER ( "Name" ) LIKE LOWER ( (SELECT "F_Name" FROM "Filter") || '%' ) OR (SELECT "F_Name" FROM "Filter") NULL )
Code: Select all
|| '%'
- MMove 1.0.6
- Extension for easy, exact positioning of shapes, pictures, controls, frames ...
- my current system
- Windows 10 AOO, LOLinux Mint AOO, LO
-
- Posts: 9
- Joined: Fri Dec 09, 2022 4:06 am
Re: SQL query with IS LIKE clause - and user entry
I'm having trouble getting the system to take the query with the input parameter function included.
The field being queried contains sentences.
I am essentially looking for any sentence which includes a search string anywhere within the sentence
So if I am looking for sentences which contain the word "nothing" the following query works:
SELECT "Person", "Category", "Quote" FROM "tblQuotes" WHERE "Quote" LIKE '*nothing*'
But when I try to change the fixed string "nothing" to an input parameter - the system indicates the query is "to complex"
SELECT "Person", "Category", "Quote" FROM "tblQuotes" WHERE "Quote" LIKE '%' || :SearchString || '%'
The field being queried contains sentences.
I am essentially looking for any sentence which includes a search string anywhere within the sentence
So if I am looking for sentences which contain the word "nothing" the following query works:
SELECT "Person", "Category", "Quote" FROM "tblQuotes" WHERE "Quote" LIKE '*nothing*'
But when I try to change the fixed string "nothing" to an input parameter - the system indicates the query is "to complex"
SELECT "Person", "Category", "Quote" FROM "tblQuotes" WHERE "Quote" LIKE '%' || :SearchString || '%'
OpenOffice Version: 6.2.8.2 - on Linux Lite
Re: SQL query with IS LIKE clause - and user entry
i wonder, just tested your query, worked for me, using HSQLDB and FIREBIRD also.
- MMove 1.0.6
- Extension for easy, exact positioning of shapes, pictures, controls, frames ...
- my current system
- Windows 10 AOO, LOLinux Mint AOO, LO
-
- Posts: 9
- Joined: Fri Dec 09, 2022 4:06 am
Re: SQL query with IS LIKE clause - and user entry
Thanks!
I wonder if there is a difference in required syntax between OO_Base versions?
OpenOffice Version: 6.2.8.2 - on Linux Lite
-
- Posts: 9
- Joined: Fri Dec 09, 2022 4:06 am
Re: SQL query with IS LIKE clause - and user entry
I just discovered there is a difference between Open Office and LibreOffice.Got_LibreOffice wrote: ↑Sun Dec 11, 2022 9:06 pmThanks!
I wonder if there is a difference in required syntax between OO_Base versions?
I am not using Open Office - I have LibreOffice
Even so - when I read the LibreOffice documentation of adding wildcards to parameters it shows the system I've tried which the system does not like.
OpenOffice Version: 6.2.8.2 - on Linux Lite
-
- Volunteer
- Posts: 1558
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: SQL query with IS LIKE clause - and user entry
Instead of a parameter you could use a Filter Table.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: SQL query with IS LIKE clause - and user entry
Combine parameter query and filter table if the filtered row set needs to be editable.
- Attachments
-
- Demo40A_FilterTable2.odb
- (25.58 KiB) Downloaded 318 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 334
- Joined: Sun Sep 06, 2020 8:27 am
Re: SQL query with IS LIKE clause - and user entry
Maybe you created a "datasource" not a database.
A source can also be a dbase-file (like the default bilbliography), a spreadsheet or even csv-Files. These are limited, and give often "to complex" as error.
The there a 2 types of databases "included", the default HSQLDB and Firebird. You find YOUR type in the lower status-bar of the database-window.
LibreOffice 7.6 on Windows 10pro and other Versions parallel
-
- Posts: 334
- Joined: Sun Sep 06, 2020 8:27 am
Re: SQL query with IS LIKE clause - and user entry
Main point: SQL does use % as a wildcard instead of the * of the file-systems.Got_LibreOffice wrote: ↑Sun Dec 11, 2022 10:38 pm ...
I just discovered there is a difference between Open Office and LibreOffice.
I am not using Open Office - I have LibreOffice
Even so - when I read the LibreOffice documentation of adding wildcards to parameters it shows the system I've tried which the system does not like.
Difference between OO and LO is quite neglectable concerning Base. LO has integrated the report-builde extension and delivers also Firebase.
LibreOffice 7.6 on Windows 10pro and other Versions parallel