If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
I have the same question. I want to find embedded percent signs as well as embedded apostrophes within a text field using AS/400 Query. Some of our text fields contain only a % or an ‘ and I want to use the LIKE.
You use the ESCAPE clause in the SQL statement to declare a symbol to mark the special character as a literal character.
SELECT * FROM TABLE WHERE C1 LIKE ‘%+%%’ ESCAPE ‘+’
first ‘%’ is wild card, ‘+%’ is a character literal of a percent sign, and the third ‘%’ is wild card; therefore, above will find any row where C1 contains a percent sign
I want to know if it is possible to do in AS/400 Query, not SQL
A SQL query is an AS/400 query; there are many kinds of AS/400 queries. If you mean that you actually want to use the old, practically obsolete, inefficient Query/400 or Query for iSeries product, I don’t know of a good way to escape the ‘%’ symbol without using SQL. (V5R3 at least can show “Query” as the product name in the list of installed products.) One might exist; I just haven’t seen one.
The best answer is simply not to keep using the old query product for anything new, and convert old queries to new ones. (That doesn’t apply to the recent Web Query product.)
Some of our text fields contain only a % or an ‘ and I want to use the LIKE.
If a field contains only a percent or apostrophe symbol, the LIKE function shouldn’t be used. Just use “equal”.
What query tool are you using? OPNQRYF? SQL? Query Manager? Query/400? Web Query? ODBC? Something else? — Tom
I have the same question. I want to find embedded percent signs as well as embedded apostrophes within a text field using AS/400 Query. Some of our text fields contain only a % or an ‘ and I want to use the LIKE.
You use the ESCAPE clause in the SQL statement to declare a symbol to mark the special character as a literal character.
SELECT * FROM TABLE WHERE C1 LIKE ‘%+%%’ ESCAPE ‘+’
first ‘%’ is wild card, ‘+%’ is a character literal of a percent sign, and the third ‘%’ is wild card; therefore, above will find any row where C1 contains a percent sign
single quote is just
SELECT * FROM TABLE WHERE C1 LIKE ‘%”%’
single quote, percent sign, single quote, single quote, percent sign, single quote
I want to know if it is possible to do in AS/400 Query, not SQL
No. A query/400 can be converted to QM Query and the resultant SQL code can be edited as shown by BigKat.
Not the answer I was hoping for, but thanks guys!
I want to know if it is possible to do in AS/400 Query, not SQL
A SQL query is an AS/400 query; there are many kinds of AS/400 queries. If you mean that you actually want to use the old, practically obsolete, inefficient Query/400 or Query for iSeries product, I don’t know of a good way to escape the ‘%’ symbol without using SQL. (V5R3 at least can show “Query” as the product name in the list of installed products.) One might exist; I just haven’t seen one.
The best answer is simply not to keep using the old query product for anything new, and convert old queries to new ones. (That doesn’t apply to the recent Web Query product.)
Some of our text fields contain only a % or an ‘ and I want to use the LIKE.
If a field contains only a percent or apostrophe symbol, the LIKE function shouldn’t be used. Just use “equal”.
Tom