Tested in MySQL:
Select * FROM table1
WHERE column1 = (
Select MAX(column1) from
(SELECT * FROM table1
WHERE LENGTH('abcdefg') > 6 AND column1 = 'abcdefg'
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 5 AND column1 = LEFT('abcdefg', 6)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 4 AND column1 = LEFT('abcdefg', 5)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 3 AND column1 = LEFT('abcdefg', 4)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 2 AND column1 = LEFT('abcdefg', 3)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 1 AND column1 = LEFT('abcdefg', 2)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 0 AND column1 = LEFT('abcdefg', 1)) as T);
Select * FROM table1
WHERE column1 = (
Select MAX(column1) from
(SELECT * FROM table1
WHERE LENGTH('abcdefg') > 6 AND column1 = 'abcdefg'
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 5 AND column1 = LEFT('abcdefg', 6)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 4 AND column1 = LEFT('abcdefg', 5)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 3 AND column1 = LEFT('abcdefg', 4)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 2 AND column1 = LEFT('abcdefg', 3)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 1 AND column1 = LEFT('abcdefg', 2)
UNION
SELECT * FROM table1
WHERE LENGTH('abcdefg') > 0 AND column1 = LEFT('abcdefg', 1)) as T);