LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-26-2007, 07:16 PM   #1
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Rep: Reputation: 15
Change table information - MySQL


Hello,

I have a database on mysql server that i was able to switch to. how would i change information in a certain table column?

Database Name: db_1
Table Name: config
Column Name: column 3

column 3 has a value of no, i would like it to say yes

what would be the correct MySQL syntax?
 
Old 03-26-2007, 07:44 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
mysql> use db_1
mysql> update config set column_3 = 'yes' where column_3 = 'no';


Is there more than one row for this column 3 and is there a space or not? The above syntac will work if there's just that one row but if you have more than one row, it's going to update all of them, unless you specify anything unique about that row you want updated. Also if this is the only row for column 3, you can disregard the where clause after 'yes', just add the ; at the end.

You should read the mysql documentation though, these are very basic commands to know when administering a MySQL database.

Last edited by trickykid; 03-26-2007 at 07:45 PM.
 
Old 03-26-2007, 08:09 PM   #3
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
thanks much! worked perfectly but just in case, how would i change it if i did have multiple rows?
 
Old 03-26-2007, 08:18 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by ballistic509
thanks much! worked perfectly but just in case, how would i change it if i did have multiple rows?
Usually a row has something unique about it, say it had an ID column as well that was incremented and this one you wanted to update with ID = 50, you would do:


mysql> use db_1
mysql> update config set column_3 = 'yes' where ID = 50;
 
Old 03-26-2007, 09:59 PM   #5
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
thanks very much!
 
  


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
MySQL db table tommytomato Linux - General 10 08-24-2004 05:57 AM
MySQL: Can't use '(' or ')' in table name Mikessu Linux - Software 0 08-03-2004 03:59 AM
MySQL non-realtime table-by-table mirroring Passive Linux - Software 1 01-20-2004 12:11 PM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM
deleted mysql table in mysql now cant do anything nakkaya Linux - Software 0 03-18-2003 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:03 AM.

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