LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-07-2013, 03:40 PM   #1
wackysiya
LQ Newbie
 
Registered: Mar 2013
Posts: 12

Rep: Reputation: Disabled
Question Sql select replace


Sql select replace
Hi All,

I had a query related to sql select replace command.
i have a table named clusters and it looks like this


Code:

name characteristics
sample 1.1 parent
sample 1.2 clone
sample 1.3 clone
sample 1.4 parent
sample 1.5 parent
sample 1.6 clone
sample 2.1 parent


I want all my entries named "sample" to" data" I need like bulk entries changed.

The table should look like this

clusters


Code:
name characteristics
data 1.1 parent
data 1.2 clone
data 1.3 clone
data 1.4 parent
data 1.5 parent
data 1.6 clone
data 2.1 parent

Is it possible using a select replace and update statement?
Please do help

I did use this

SELECT REPLACE ('clusters','sample','data');

but it didnt work

I also thought it might because of spacing between sample and number
I used this

SELECT REPLACE ('cluster','sample*','data*');
but that didnt work too.

Please advise
 
Old 05-07-2013, 06:10 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If the table is named 'clusters' & the column is named 'name', then
Code:
update clusters
set name='data'
where name = 'sample';

commit;
https://dev.mysql.com/doc/refman/5.1/en/update.html
In fact you should bookmark that entire site, if you use MySQL.
If you use another DB, bookmark the relevant site and read it.

The code above is basic SQL, so should work on any RDBMS.

Last edited by chrism01; 05-07-2013 at 06:11 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL select/NULL question action_owl Programming 3 12-23-2010 08:24 PM
sql - select, count, join, group true_atlantis Programming 1 11-19-2008 10:07 PM
SQL SELECT Group by 2 conditions MicahCarrick Programming 1 01-30-2007 10:02 PM
Sql + Oracle Select If ???? smaida Programming 11 12-15-2004 08:13 PM
Bizarre SQL select query acid_kewpie Programming 6 01-20-2004 12:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration