简体   繁体   English

两个特殊字符之间的字符串impala sql

[英]string between two special characters impala sql

Hi all I am trying to write sql for selecting string between two special characters. 大家好,我正在尝试编写用于在两个特殊字符之间选择字符串的sql。

example: in the table, field value like 7185878969-129981041-000000 . 示例:在表中,字段值类似7185878969-129981041-000000。 how can I select only middle portion 129981041 without hard coding. 如何仅选择中间部分129981041而无需进行硬编码。 What will be the best way to go about this?.Please provide sample code. 最好的方法是什么?请提供示例代码。 Thanks 谢谢

Impala具有split_part()

select split_part(col, '-', 2)

Try this for MySQL: 对于MySQL,请尝试以下操作:

SELECT REVERSE(SUBSTRING_INDEX(REVERSE(SUBSTRING_INDEX(Column,'-',2)),'-',1))
FROM table_name;

Result : 结果

129981041

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM