If you ever need to reverse the order of a string value in MySQL – that is, return a string with the order of the characters reversed – the REVERSE()
function is what you need.
Category: Relational
How to Return a String in Reverse Order using SQL Server – REVERSE()
Starting from SQL Server 2008, the REVERSE()
function can be used to reverse the order of a string. That is, it returns the characters in the string in reverse order.
Here’s the syntax:
REVERSE ( string_expression )
Where string_expression
is an expression of a string or binary data type. It can be a constant, variable, or column of either character or binary data.
The Easiest Way to Add Multiple Spaces to a String in MySQL – SPACE()
Occasionally when working with MySQL databases, you might find yourself needing to add multiple space characters to a string.
Maybe you need to pad a string by adding leading or trailing spaces. Or maybe you need to replace a single space within the string with many spaces. Either way, MySQL has the SPACE()
function to help you.
The SPACE()
function is an easy way for you to return as many space characters as you need.
3 Ways to Return a String of Multiple Spaces in SQL Server
When working with databases and the associated data, sometimes you need to insert a space when joining two strings together, or sometimes you need to replace a character with a space.
And then sometimes you need to insert multiple spaces. Here are 3 ways to return a string of multiple spaces in SQL Server using T-SQL.
How to Remove Leading and Trailing Characters in MySQL
MySQL has a TRIM()
function that enables you to remove leading and/or trailing whitespace from a string.
You can also use it to remove other specified characters from either side (or both sides) of the string.
This article explains how to remove specified leading/trailing characters from the string.
How to Remove Leading and Trailing Whitespace in MySQL
MySQL has a TRIM()
function that enables you to remove leading and/or trailing whitespace from a string.
You can also use it to remove other specified characters from either side (or both sides) of the string.
This article focuses on removing whitespace from both sides of the string.
How to Remove Leading Whitespace in MySQL
MySQL has the LTRIM()
function that enables you to remove leading whitespace from a string (space at the start of the string).
MySQL also has the TRIM()
function that enables you to remove leading space, trailing space (at the end), space from both sides, or to remove other specified characters from either side (or both sides) of the string.
This article demonstrates how to remove leading space using each of these functions.
How to Remove Trailing Whitespace in MySQL
MySQL has an RTRIM()
function that enables you to remove trailing whitespace from a string (space at the end of the string).
MySQL also has the TRIM()
function that enables you to remove trailing space, leading space (at the start), space from both sides, or to remove other specified characters from either side (or both sides) of the string.
This article demonstrates how to remove trailing space using each of these functions.
How to Remove Leading and Trailing Characters in SQL Server
In SQL Server, the TRIM()
function is commonly used to remove leading and trailing whitespace from a string. But did you know that you can also remove other characters from the start/end of a string? It doesn’t have to be whitespace.
TRIM()
is a T-SQL function that specifically removes the space character char(32)
or other specified characters from the start or end of a string.
How to Remove Leading and Trailing Whitespace in SQL Server
In SQL Server, you can use the TRIM()
function to remove leading and trailing whitespace from a string.
TRIM()
is a T-SQL function that removes the space character char(32)
or other specified characters from the start or end of a string.