Getting x characters from text
I have this SQL statement: SELECT ID, title, date, content FROM news ORDER BY date asc LIMIT 0,10 However, I only need the first 40 characters of the content field, which in some cases is over 5000 characters long. Is there a way to request only the first 40 characters of a field? Thanks in advance. Dotan Cohen http://www.technology-sleuth.com/mobile/cellphones.php -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Getting x characters from text
At 19:48 +0300 10/4/05, Dotan Cohen wrote: I have this SQL statement: SELECT ID, title, date, content FROM news ORDER BY date asc LIMIT 0,10 However, I only need the first 40 characters of the content field, which in some cases is over 5000 characters long. Is there a way to request only the first 40 characters of a field? Thanks in advance. LEFT(str,len) ? http://dev.mysql.com/doc/mysql/en/string-functions.html -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Getting x characters from text
SELECT ID, title, date, left(content,40) FROM news ORDER BY date asc LIMIT 0,10 If you want the last 40, use right(), and if you want to choose a section, use the mid() function. HTH, J.R. -Original Message- From: Dotan Cohen [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 04, 2005 12:48 PM To: mysql@lists.mysql.com Subject: Getting x characters from text I have this SQL statement: SELECT ID, title, date, content FROM news ORDER BY date asc LIMIT 0,10 However, I only need the first 40 characters of the content field, which in some cases is over 5000 characters long. Is there a way to request only the first 40 characters of a field? Thanks in advance. Dotan Cohen http://www.technology-sleuth.com/mobile/cellphones.php -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature