[英]Select rows that has mixed charcters in a single value e.g. 'Joh?n' in name column
In an oracle table: 在oracle表中:
1- a value in a VARCHAR column contains characters that are not letters. 1-VARCHAR列中的值包含不是字母的字符。
Consider a scenarion where a name in 'last_name' column contains regular characters (A - Z, a - z) as well as characters that are not english letters (eg '.', '-', ' ','_', '>' or similar). 考虑一个方案,其中“ last_name”列中的名称包含常规字符(A-Z,a-z)以及非英语字母的字符(例如“。”,“-”,“,” _, >”或类似)。
The challenge is to select the rows that has names in 'last_name' as '.John' or 'John.' 面临的挑战是选择名称在“ last_name”中作为“ .John”或“ John”的行。 or '-John' or 'Joh-n' 或'-John'或'Joh-n'
2- Is it possible to have non-date values in a Date defined column? 2-是否可以在“日期定义的”列中包含非日期值? If yes, how can such records be selected in an oracle query? 如果是,如何在oracle查询中选择此类记录?
Thanks! 谢谢!
I believe this will do the trick: 我相信这可以解决问题:
SELECT * FROM mytable WHERE REGEXP_LIKE(last_name, '[^A-Za-z]');
As for your 2nd question, I am unsure. 至于第二个问题,我不确定。 I would be glad if someone else could add on to what I have to answer your 2nd question. 如果有人可以补充我要回答的第二个问题,我将感到非常高兴。 I have found this website thought that might be of help. 我发现该网站认为可能会有帮助。 http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html It explains the DATE format. http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html解释了DATE格式。
If I properly understand your goal, you need to select rows with last_name column containing the name 'John', but it may also have additional characters before, after, or even inside the name. 如果我正确理解了您的目标,则需要选择last_name列中包含名称“ John”的行,但是该名称之前,之后甚至内部可能还会有其他字符。 In that case, this should be helpful: 在这种情况下,这将有所帮助:
select * from tab where regexp_replace(last_name, '[^A-Za-z]+', '') = 'John'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.