简体   繁体   English

选择在单个值中包含混合字符的行,例如名称列中的“ Joh?n”

[英]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.

相关问题 选择具有混合值的N行 - Select N Rows With Mixed Values 列名带有数字前缀(例如3name)是否合法? - Is it valid syntax to have a column name prefixed with a number, e.g., 3name? 哪个 SQL 子句和 function 允许您过滤关于一个值的数据? (例如,由单个客户或在单个日期进行的购买) - Which SQL clause and function allows you to filter for data about one value? (e.g. purchases made by a single customer or on a single date) Oracle - 有序列 ID 例如 ORDER BY 1 被允许在哪里? - Oracle - where the orderly column ID e.g. ORDER BY 1 is allwed? 有没有一种方法可以使用可以将多个列作为输入的函数(例如`GREATEST`)而无需输入每个列名? - Is there a way to use functions that can take multiple columns as input (e.g. `GREATEST`) without typing out every column name? 我可以从参数中选择*吗(例如@tableName) - Can I SELECT*FROM a parameter (e.g. @tableName) 选择列值已更改的行 - Select rows where column value has changed SQL:选择列值至少出现N次的行? - SQL: Select rows with a column value that occurs at least N times? 为该列的每个唯一值选择最多N行 - select up to N rows for each unique value of the column 如何使用PHP仅选择一列时间(例如10:15、10:35),如何将其与当前时间进行比较? - How do I select only a column of times (e.g., 10:15, 10:35) using PHP and how can I compare those with the current time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM