Posted By: Anonymous
Was wondering if it’s possible to select something that has more/less than x characters in SQL.
For example, I have an employee table and I want to show all employee names that has more than 4 characters in their name.
Here’s an example table
ID EmpName Dept 1 Johnny ACC 2 Dan IT 3 Amriel PR 4 Amy HR
If you are using SQL Server, Use the
LEN (Length) function:
SELECT EmployeeName FROM EmployeeTable WHERE LEN(EmployeeName) > 4
MSDN for it states:
Returns the number of characters of the specified string expression,
excluding trailing blanks.
For oracle/plsql you can use
Length(), mysql also uses Length.
Here is the Oracle documentation:
And here is the mySQL Documentation of
For PostgreSQL, you can use
char_length(string). Here is the PostgreSQL documentation: