I have a database with a large number of words but i want to select only those records where the character length is equal to a given number (in example case 3):
$query = ("SELECT * FROM $db WHERE conditions AND length = 3");
But this does not work... can someone show me the correct query?
This question is related to
sql
conditional-statements
where
I think you want this:
select *
from dbo.table
where DATALENGTH(column_name) = 3
SELECT *
FROM my_table
WHERE substr(my_field,1,5) = "abcde";
Source: Stackoverflow.com