0
I’m trying to select only 5 characters from the field description
, tried several ways and it doesn’t work, the eating I’m giving is this:
SELECT description = CASE WHEN LEN(description) > 5 THEN LEFT(description,5) ELSE description END AS description FROM contentphp
What’s the mistake I can’t find? (I am using MYSQL)
instead of LEN, tried char_lenght()?
– Filipe L. Constante
I tried but he says there is no such command.
– Anorak
I don’t have mysql here p/ test.. :(
– Filipe L. Constante
I don’t understand the reason of the case, do you want to select only the first 5? Try: "SELECT LEFT(Description,5) AS Description FROM contentphp"
– Leonardo Buta
Test here (on oracle) and worked: SELECT (CASE WHEN CHAR_LENGTH(Description) > 5 then LEFT('Description',5) Else 'Description ' end) AS Description FROM contentphp;
– Filipe L. Constante
@Constant worked now that you posted it... the difference is that you put the command between parentheses.
– Anorak
Okay, mark the right answer.. :)
– Filipe L. Constante