Jump to content


sql statement .. select part of a field?

  • Please log in to reply
1 reply to this topic

#1 n8w

  • Members
  • PipPipPip
  • Advanced Member
  • 123 posts

Posted 17 March 2006 - 06:46 PM


I have a colum in a table that is an id .. and I have a prefix of "999" on the id (I know this wasn't the best table structure .. but I am retrofitting something.)

for example id 1 looks like
id 2 looks like

etc ..

I would like to select this column but just the characters after the first "999" which would be 1,2,etc

something like select id(after 3 chars) from mytable


#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 17 March 2006 - 08:36 PM

MySql SUBSTRING function. Similar to php substr except first position is 1 in MySql

SELECT SUBSTRING(id, 4) as id FROM mytablename

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users