Outside of a query you could do something like... - Loop through all your delimiters getting the first index of each. So . may be at index 29, ! at index 40 and ? at index 18.
- Use the lowest one in your query below to denote the end of the first sentence. In a query, how about... - Replace all possible ends of sentences with a full stop (period). - Then look for the first occurrence. Something like... SELECT SUBSTRING_INDEX(REPLACE(j.job_desc, '!', '.'), '.', 1) AS job_desc FROM jobs You'll need to nest more REPLACEs for each possible sentence end char. Ade -----Original Message----- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: 09 January 2006 15:35 To: CF-Talk Subject: SOT: SQL query to get first sentence (using mySQL) I've got a text field from which I'd like to extract the first sentence for each record. Here's the query I've got so far. SELECT SUBSTRING_INDEX(j.job_desc,'.',1) AS job_desc FROM jobs The problem is that in some of the records, the first sentence is terminated by a question mark (or exclamation point) rather than a period and I need to get those sentences as well. I'm trying to find out how I can say "the first sentence" instead of "the first sentence ending in a period". Does anyone have any ideas? <!----------------//------ andy matthews web developer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --------------//---------> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229028 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54