In order to be able to simulate substr from PHP and mysql, I want to do something like
select * from table where last_four_chars(field) = '.png'
In order to be able to simulate substr from PHP and mysql, I want to do something like
select * from table where last_four_chars(field) = '.png'
The docs have an example directly relevant to this.
select * from table where SUBSTRING(field, -4) = '.png'
With RIGHT function :
SELECT RIGHT('abcdefg', 3);
-- efg
You can achieve the same result with SUBSTRING :
SELECT SUBSTRING('abcdefg', -3);
-- efg
This Fast query:
Select * from table where picName like '%.png'
SELECT * FROM table WHERE SUBSTRING( field, -4 ) = '.png'