Lead-In Sentence fragment...

Submitted by:David Villa

Date added:13 June, 2016

Category:MySQL

As a "preview" of text, this MySQL select will return the first few words out of a text field in a database. It returns entire words (doesn't cut them off in the middle) and follows the last word with an elipse "..."

Tags: fragment

Code Snippet:

SELECT CONCAT(LEFT(NameOfField,LOCATE(' ',NameOfField,$CharsToDisplay)-1),'...')
FROM TheTable
WHERE TheID = $TheID
 
 

Comments