[英]DB2 SELECT using alpha wildcard and the length of 4 characters
I need to do a SELECT for a product_id where the length the product_id is 4 characters long and the last character can be any letter. 我需要对product_id进行SELECT,其中product_id的长度为4个字符,最后一个字符可以是任何字母。 I know the wildcard for selecting any letters but I don't know how to denote that it has to be the last character and that the product_ids I'm looking for must be 4 characters long.
我知道选择任何字母的通配符,但我不知道如何表示它必须是最后一个字符,并且我要查找的product_id必须长4个字符。
Does that make sense? 那有意义吗?
Have you tried RIGHT and standard LIKE? 您是否尝试过RIGHT和标准LIKE? (There is a LEFT in DB2).
(DB2中有一个LEFT)。 If not, SUBSTR.
如果不是,请按SUBSTR。
In DB2 you can use LENGTH 在DB2中,您可以使用LENGTH
So hopefully 所以希望
WHERE
RIGHT(product_id, 1) LIKE [A-Z] AND LEN(product_id) = 4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.