I have an sql query to perform,
I have a column named as ringSetName
with entries like
DFWR001921S
DFWER923231
Etc i want to get all entries with last character as S
I have tried using
SELECT *
FROM rings
WHERE ringSetName LIKE '%s'
LIMIT 0 , 30
It doesn't work
You can try using uppercase S
if you use a case-sensitive collation
WHERE ringSetName LIKE '%S'
Otherwise it should work. See this example from SQLFiddle
You can use substring()
SELECT *
FROM rings
WHERE UPPER(SUBSTRING(ringSetName,-1)) = 'S'
LIMIT 0 , 30
This may be helpful, use it.
SELECT *
FROM rings
WHERE TRIM(ringSetName) LIKE '%s$'
LIMIT 0 , 30
SELECT *
FROM rings
WHERE ringSetName REGEXP '.*[sS]$'
LIMIT 0 , 30
SELECT * FROM rings WHERE UPPER(ringSetName) like '%S' LIMIT 0 , 30;
SELECT *
FROM rings
WHERE ringSetName LIKE '%s' COLLATE utf8_general_ci
_ci
means case_insensitive
also check your last character for ' '
white space situation.
If that returns some rows which has ' '
, you should trim your rows.
SELECT *
FROM rings
WHERE ringSetName LIKE '% '