Jump to content


Photo

please check if correct


  • Please log in to reply
2 replies to this topic

#1 mATOK

mATOK
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts
  • LocationToronto, Ontario

Posted 16 August 2006 - 01:34 PM

hey there, I have a column of type varchar that contains something that looks liek the following

Cat 002
Cat 002
Cat 003
Cat 005
Cat 107

etc

What I would like to do is remove the 'Cat ' from every record and be left with only the three digit number.

do I want to execute - UPDATE substring(category, 5, len(category)-4) ?

I'm pretty new to these types of commands and would apreciate confirmation / correction.

thanx
"Not everything that counts can be counted, and not everything that can be counted counts."

W3 Web Tutorials | Check Your html | CSS layout techniques | ALA | Zen Garden | CSS Links

Navs with flavor | CSS Playground | CSS boxes

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 16 August 2006 - 04:00 PM

If it's always 3 digits, you can do the following:

UPDATE yourTable SET yourColumn = RIGHT( yourColumn, 3)

But you'd probably want to run an equivalent select query first just to be sure.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 mATOK

mATOK
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts
  • LocationToronto, Ontario

Posted 21 August 2006 - 01:15 PM

Thank You! :D
"Not everything that counts can be counted, and not everything that can be counted counts."

W3 Web Tutorials | Check Your html | CSS layout techniques | ALA | Zen Garden | CSS Links

Navs with flavor | CSS Playground | CSS boxes




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users