Be Excellent To Each Other

And, you know, party on. Dude.

All times are UTC [ DST ]




Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:19 
User avatar

Joined: 31st Mar, 2008
Posts: 8653
Right, my brain has shut down due to lack of sleep, so I really just want someone to tell me how to do this as I am clearly rubbish.

I have a load of part numbers in a table that should be AS1-..., unfortunately, some genius has been putting them in as ASI-...
How can I update the ASI- to AS1-?


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:22 
User avatar

Joined: 30th Mar, 2008
Posts: 14321
Location: Shropshire, UK
UPDATE `table` SET `column`=REPLACE(`column`, 'ASI-', 'AS1-');


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:23 
User avatar
UltraMod

Joined: 27th Mar, 2008
Posts: 55717
Location: California
Isn't it something like:
Code:
update table_name
     set row1 = "AS1-"
     where row1 = "ASI-"


I haven't done SQL for about three years now, though, so it could be wrong. :(

_________________
I am currently under construction.
Thank you for your patience.


Image


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:25 
User avatar

Joined: 31st Mar, 2008
Posts: 8653
GazChap wrote:
UPDATE `table` SET `column`=REPLACE(`column`, 'ASI-', 'AS1-');


Yeah, this dawned on me after I'd posted. Done it now, thanks anyway.


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:26 
User avatar

Joined: 31st Mar, 2008
Posts: 8653
myp wrote:
Isn't it something like:
Code:
update table_name
     set row1 = "AS1-"
     where row1 = "ASI-"


I haven't done SQL for about three years now, though, so it could be wrong. :(


Oh my god, yes, it's wrong. :p
(Although technically, that probably wouldn't have done anything :p )


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:35 
User avatar
UltraMod

Joined: 27th Mar, 2008
Posts: 55717
Location: California
Every time I learn something new it pushes old stuff out of my brain. :(

_________________
I am currently under construction.
Thank you for your patience.


Image


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 12:41 
User avatar

Joined: 31st Mar, 2008
Posts: 8653
myp wrote:
Every time I learn something new it pushes old stuff out of my brain. :(


I know the feeling, except it always pushes the useful stuff out, rather than all the pointless stuff that I can still remember. :(


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 13:28 
SupaMod
User avatar
Commander-in-Cheese

Joined: 30th Mar, 2008
Posts: 49237
To be fair, if the values were actually 'AS1-' rather than 'AS1-XXXXXXX', myp's answer would have been fine.

_________________
GoddessJasmine wrote:
Drunk, pulled Craster's pork, waiting for brdyime story,reading nuts. Xz


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 13:30 
User avatar
Pyrotechnician!!!1

Joined: 13th Jul, 2009
Posts: 3357
Location: Stockport
Craster wrote:
To be fair, if the values were actually 'AS1-' rather than 'AS1-XXXXXXX', myp's answer would have been fine.

Hush, don't defend him.

_________________
Image

WARNING!!! DO NOT CLICK THIS UNLESS YOU CAN HANDLE THE SIGHT OF MAXIMUM PWNAGE!!!


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 13:33 
User avatar
UltraMod

Joined: 27th Mar, 2008
Posts: 55717
Location: California
Actually, I didn't even notice that. I just thought Joans was putting ellipses in to finish his sentences. :S

_________________
I am currently under construction.
Thank you for your patience.


Image


Top
 Profile  
 
 Post subject: Re: Dumb SQL questions
PostPosted: Wed Sep 16, 2009 14:39 
User avatar

Joined: 31st Mar, 2008
Posts: 8653
Craster wrote:
To be fair, if the values were actually 'AS1-' rather than 'AS1-XXXXXXX', myp's answer would have been fine.


Yeah, but if that was the case, I shouldn't have needed to ask the question (although you might say I shouldn't have needed to anyway).


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search within this thread:
You are using the 'Ted' forum. Bill doesn't really exist any more. Bogus!
Want to help out with the hosting / advertising costs? That's very nice of you.
Are you on a mobile phone? Try http://beex.co.uk/m/
RIP, Owen. RIP, MrC. RIP, Dimmers.

Powered by a very Grim... version of phpBB © 2000, 2002, 2005, 2007 phpBB Group.