MySQL/SQL retrieve first 40 characters of a text field?

后端 未结 5 2205
无人及你
无人及你 2020-12-01 10:39

How can I retrieve a text field from mysql db table, but not the entire text, just the few 40 or so characters.

Can this be done in sql or do I need to do it using p

5条回答
  •  不思量自难忘°
    2020-12-01 10:59

    SELECT LEFT(MY_COLUMN, 40) FROM MY_TABLE
    

    Function in the MySQL reference manual:

    http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left

提交回复
热议问题