40 pts.
 Wild card search in AS/400 query
How do I find records that actually have percent sign in them using the like '%  "%"  %' when the % is the wild card?

Software/Hardware used:
AS/400 Query
ASKED: September 17, 2012  8:06 PM
UPDATED: September 18, 2012  12:53 PM

Answer Wiki:
Is it always in the same position in the file?
Last Wiki Answer Submitted:  September 17, 2012  9:35 pm  by  CharlieBrowne   32,905 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,905 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

What query tool are you using? OPNQRYF? SQL? Query Manager? Query/400? Web Query? ODBC? Something else? — Tom

 108,225 pts.

 

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.

 40 pts.

 

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

 7,185 pts.

 

single quote is just
SELECT * FROM TABLE WHERE C1 LIKE ‘%”%’
single quote, percent sign, single quote, single quote, percent sign, single quote

 7,185 pts.

 

I want to know if it is possible to do in AS/400 Query, not SQL

 40 pts.

 

No.  A query/400 can be converted to QM Query and the resultant SQL code can be edited as shown by BigKat. 

 44,190 pts.

 

Not the answer I was hoping for, but thanks guys!

 40 pts.

 

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

 108,225 pts.