should it not be: SELECT date, substring(text,1,30) as....
string length starts at position "1". substring, therefore, would consider the first character of the string as position 1, not 0. ----- Original Message ----- From: "Nick Wilson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 13, 2002 6:03 PM Subject: use of substring() > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all, > I'm having a spot of bother with the SUBSTRING() function, I don't think > I understand it properly... > > I have a table (for example) with three cols 'id' | 'date' | 'text' > I want to return just 'date' and the first 30 chars from 'text' > > I've tried this sql: > > SELECT date, SUBSTRING(text, 0,30) as description FROM table WHERE id = > '2'; > > to no avail. > > Could someone please explain what I *should* be doing? > > Many thanks... > - -- > Nick Wilson // www.explodingnet.com > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.6 (GNU/Linux) > > iD8DBQE9CRXfHpvrrTa6L5oRAoS9AKC064XvuD46+UcbV9V+jLMYNOCQrACfY9WX > eKfDM1z+wx6niPo1uPx7Bek= > =RpXZ > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php