Substring () for fields in MYSQL

I do not understand why this did not work:

select id,name,concat(substring(description,0,30),'...') as desc_shortened, created_date,added_by from products 

Even if there is data inside the description field. I have not seen any example fields in mySQL documentation. They used blank rows instead of column names.

concat(susbtring(description,0,30)) returns only ... and that’s it.

+4
source share
2 answers

Use substring(description,1,30) instead.

+8
source

Oracle treats 0 as 1 in this function, but mysql treats 0 as empty.To you should use a substring (description, 1.30).

0
source

All Articles