Re: ?? What character escapes wildcards % and _ for SELECTing literal % or _ ??
Also, the command Query node *-* works Computer says 'No'.. -Original Message- From: ADSM: Dist Stor Manager [mailto:[EMAIL PROTECTED] On Behalf Of TSM_User Sent: Thursday, June 23, 2005 1:52 AM To: ADSM-L@VM.MARIST.EDU Subject: Re: ?? What character escapes wildcards % and _ for SELECTing literal % or _ ?? Looks like when you want to actually search for an _ or % you have to tell SQL what character you want to use as an escape. I couldn't find anything that said what the default escape character is so maybe this is the only way to do it. Anyway here is what works select node_name from nodes where node_name like '%\_%' escape '\' When you use the word escape followed by quotes and any character in the quotes that character will be treated like an escape character. So the following will work also select node_name from nodes where node_name like '%!_%' escape '!' google is my friend I searched for escape character for SQL selects and the first hit was an example. I then tested it and it appears to work. The page that came up was http://www.techonthenet.com/sql/like.htm. This page had a lot of good information where it explains Kyle James R Owen [EMAIL PROTECTED] wrote: [Hey: If you're really in a hurry, skip to the next page, and see (@), but you might miss some fun(ny, perhaps even useful?) stuff!] I just accidentally discovered [!much to my surprise!] that... The underscore _ character is the SQL SELECT standard wildcard to match any single character in the specified position, e.g., select node_name from nodes where node_name like '_A_' [lists all nodes w/ names 3 characters long w/ 'A' in the middle. [Probably] we all[ready] know [or have discovered] that... The percent % character is the SQL SELECT standard wildcard to match zero or more characters [but NOT a NULL string!] select node_name from nodes where node_name like '%-%' [lists all nodes w/ hyphenated names, and also bizarre names like '-', '+-', '1-0', '.-.', '...---...' (morse code!), etc.] Now, what I really want is a list of nodes w/ names including a literal underscore _ character so I first tried... select node_name from nodes where node_name like '%_%' [which seems to be exactly equivalent to...] select node_name from nodes where node_name like '%' [Both list all existing nodes (because node_name can't be null!)] Then I borrowed an Oracle DBA's SQL ref.manual and found... The backslash / character is the SQL SELECT standard escape used preceding a wildcard to match that (following) character literally. (@) So, I tried again... tsm: TSTselect node_name from nodes where node_name like '%\_%' ANR2034E SELECT: No match found using this criteria. ANS8001I Return code 11. tsm: TSTselect node_name from nodes where node_name like '%_OB' NODE_NAME -- xx_OB y-OB z_OB aaa_OB _OB OB tsm: TST [names partially changed to protect the innocent] !!!What to do??? [Please, don't say there's no escape!] ITSM 5.2.3.0 w/ AIX 5.2 -- [EMAIL PROTECTED] (203.432.6693) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Disclaimer Notice __ This message and any attachments are confidential and should only be read by those to whom they are addressed. If you are not the intended recipient, please contact us, delete the message from your computer and destroy any copies. Any distribution or copying without our prior permission is prohibited. Internet communications are not always secure and therefore Powergen Retail Limited does not accept legal responsibility for this message. The recipient is responsible for verifying its authenticity before acting on the contents. Any views or opinions presented are solely those of the author and do not necessarily represent those of Powergen Retail Limited. Powergen Retail Ltd is authorised and regulated by the Financial Services Authority for the sale and service of general insurance products. Registered addresses: Powergen Retail Limited, Westwood Way, Westwood Business Park, Coventry, CV4 8LG. Registered in England and Wales No: 3407430 Telephone +44 (0) 2476 42 4000 Fax +44 (0) 2476 42 5432
?? What character escapes wildcards % and _ for SELECTing literal % or _ ??
[Hey: If you're really in a hurry, skip to the next page, and see (@), but you might miss some fun(ny, perhaps even useful?) stuff!] I just accidentally discovered [!much to my surprise!] that... The underscore _ character is the SQL SELECT standard wildcard to match any single character in the specified position, e.g., select node_name from nodes where node_name like '_A_' [lists all nodes w/ names 3 characters long w/ 'A' in the middle. [Probably] we all[ready] know [or have discovered] that... The percent % character is the SQL SELECT standard wildcard to match zero or more characters [but NOT a NULL string!] select node_name from nodes where node_name like '%-%' [lists all nodes w/ hyphenated names, and also bizarre names like '-', '+-', '1-0', '.-.', '...---...' (morse code!), etc.] Now, what I really want is a list of nodes w/ names including a literal underscore _ character so I first tried... select node_name from nodes where node_name like '%_%' [which seems to be exactly equivalent to...] select node_name from nodes where node_name like '%' [Both list all existing nodes (because node_name can't be null!)] Then I borrowed an Oracle DBA's SQL ref.manual and found... The backslash / character is the SQL SELECT standard escape used preceding a wildcard to match that (following) character literally. (@) So, I tried again... tsm: TSTselect node_name from nodes where node_name like '%\_%' ANR2034E SELECT: No match found using this criteria. ANS8001I Return code 11. tsm: TSTselect node_name from nodes where node_name like '%_OB' NODE_NAME -- xx_OB y-OB z_OB aaa_OB _OB OB tsm: TST[names partially changed to protect the innocent] !!!What to do???[Please, don't say there's no escape!] ITSM 5.2.3.0 w/ AIX 5.2 -- [EMAIL PROTECTED] (203.432.6693)
Re: ?? What character escapes wildcards % and _ for SELECTing literal % or _ ??
Looks like when you want to actually search for an _ or % you have to tell SQL what character you want to use as an escape. I couldn't find anything that said what the default escape character is so maybe this is the only way to do it. Anyway here is what works select node_name from nodes where node_name like '%\_%' escape '\' When you use the word escape followed by quotes and any character in the quotes that character will be treated like an escape character. So the following will work also select node_name from nodes where node_name like '%!_%' escape '!' google is my friend I searched for escape character for SQL selects and the first hit was an example. I then tested it and it appears to work. The page that came up was http://www.techonthenet.com/sql/like.htm. This page had a lot of good information where it explains Kyle James R Owen [EMAIL PROTECTED] wrote: [Hey: If you're really in a hurry, skip to the next page, and see (@), but you might miss some fun(ny, perhaps even useful?) stuff!] I just accidentally discovered [!much to my surprise!] that... The underscore _ character is the SQL SELECT standard wildcard to match any single character in the specified position, e.g., select node_name from nodes where node_name like '_A_' [lists all nodes w/ names 3 characters long w/ 'A' in the middle. [Probably] we all[ready] know [or have discovered] that... The percent % character is the SQL SELECT standard wildcard to match zero or more characters [but NOT a NULL string!] select node_name from nodes where node_name like '%-%' [lists all nodes w/ hyphenated names, and also bizarre names like '-', '+-', '1-0', '.-.', '...---...' (morse code!), etc.] Now, what I really want is a list of nodes w/ names including a literal underscore _ character so I first tried... select node_name from nodes where node_name like '%_%' [which seems to be exactly equivalent to...] select node_name from nodes where node_name like '%' [Both list all existing nodes (because node_name can't be null!)] Then I borrowed an Oracle DBA's SQL ref.manual and found... The backslash / character is the SQL SELECT standard escape used preceding a wildcard to match that (following) character literally. (@) So, I tried again... tsm: TSTselect node_name from nodes where node_name like '%\_%' ANR2034E SELECT: No match found using this criteria. ANS8001I Return code 11. tsm: TSTselect node_name from nodes where node_name like '%_OB' NODE_NAME -- xx_OB y-OB z_OB aaa_OB _OB OB tsm: TST [names partially changed to protect the innocent] !!!What to do??? [Please, don't say there's no escape!] ITSM 5.2.3.0 w/ AIX 5.2 -- [EMAIL PROTECTED] (203.432.6693) __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com