sql reverse
时间: 2023-09-19 15:10:22 浏览: 71
In SQL, there is no built-in function specifically for reversing strings. However, you can achieve the reverse effect by using a combination of functions.
Here is an example of how you can reverse a string in SQL using the `REVERSE` function:
```sql
SELECT REVERSE('Hello World') AS ReversedString;
```
This will return the reversed string `'dlroW olleH'`.
Keep in mind that the `REVERSE` function might not be available in all database systems. If you are using a different database, you may need to refer to its documentation for alternative methods of achieving string reversal.
相关问题
prestosql reverse
在Presto SQL中,要对一个字符串进行反转操作,可以使用REVERSE函数。REVERSE函数会将字符串中的字符顺序进行反转,并返回反转后的结果。
以下是一个示例查询,展示了如何使用REVERSE函数进行字符串反转:
```
SELECT REVERSE('Hello, World!') AS reversed_string;
```
运行以上查询,将返回反转后的字符串结果:
```
dlroW ,olleH
```
希望这能帮到你!如果还有其他问题,请随时提问。
SELECT sno, SUBSTRING( sno,1, LENGTH( sno ) - INSTR( REVERSE( sno ), '-' ) ) product_model FROM device_extend 把这个sql按sqlserver重写
在 SQL Server 中,可以使用 SUBSTRING 函数和 CHARINDEX 函数来重写该 SQL 语句。具体实现如下:
```
SELECT
sno,
SUBSTRING(sno, 1, LEN(sno) - CHARINDEX('-', REVERSE(sno))) AS product_model
FROM device_extend
```
其中,LEN 函数用于获取字符串长度,CHARINDEX 函数用于查找字符串中指定子串的位置。REVERSE 函数用于反转字符串。
阅读全文