Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substring() for Fields in MYSQL

Tags:

mysql

I don't understand why this didn't work out:

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

Even though there is data inside of the description field. I didn't see any field example on mySQL documentation tho. They used pure strings instead of column names.

concat(susbtring(description,0,30)) only returns ... and that's all.

like image 863
Tarik Avatar asked Feb 24 '23 12:02

Tarik


1 Answers

Use substring(description,1,30) instead.

like image 107
a'r Avatar answered Feb 26 '23 21:02

a'r