use of substring()

2002-06-13 Thread Nick Wilson
-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

Re: use of substring()

2002-06-13 Thread Julie Meloni
Hi - NW I have a table (for example) with three cols 'id' | 'date' | 'text' NW I want to return just 'date' and the first 30 chars from 'text' NW I've tried this sql: NW SELECT date, SUBSTRING(text, 0,30) as description FROM table WHERE id = NW '2'; Start with position 1. SELECT datefield,

Re: use of substring()

2002-06-13 Thread Keith C. Ivey
On 14 Jun 2002, at 0:03, Nick Wilson wrote: SELECT date, SUBSTRING(text, 0,30) as description FROM table WHERE id = '2'; You can't assume that MySQL is like Perl, PHP, or any other language you may be used to. Note this: For functions that operate on string positions, the first position is

Re: use of substring()

2002-06-13 Thread MikeParton
, 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

Re: use of substring()

2002-06-13 Thread Nick Wilson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Julie Meloni declared Start with position 1. SELECT datefield, SUBSTRING(textfield, 1, 30) as description FROM tablename WHERE id = 2; Hi again Julie and thanks for 'cross list' help! The problem is not that, at least not first

Re: use of substring()

2002-06-13 Thread Nick Wilson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Nick Wilson declared You have an error in your SQL syntax near 'desc FROM news ORDER BY date ' at line 1 Ooops, reserved word! Works great ;-) Any way to add something to it like or should I do that in my php? Many thanks