Unix/Linux Go Back    


UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

SQL - how to alter info of a cell in table

UNIX and Linux Applications


Tags
solved, sql

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-18-2016
baris35 baris35 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 19 May 2017, 9:22 PM EDT
Posts: 98
Thanks: 43
Thanked 4 Times in 4 Posts
SQL - how to alter info of a cell in table

Hello,
I am newbie on mysql and trying to edit my database from terminal under linux.
What I need to do is to change the information written in a cell in table.
Let me explain what I tried:


Code:
$ mysql -u mysqluser -p
$ show databases;
$ USE catalogue;
$ show tables ;
$ select * from phonebook;

it shows something like this:

+-------------+------------+--------+
| id | friend_name | age |
+-------------+------------+--------+
| 1 | Jaxier | 18 |
| 2 | Johanna | 26 |
| 3 | Johny | 25 |
| 4 | Lacatus | 18 |
| 5 | Julia | 25 |
+-------------+------------+---------+

What I want to do is to set age of Lacatus from 18 to 58

I tried below commands:

1)

Code:
$ update phonebook set id 4 SET age 58;

gives syntax error.

2)

Code:
$  ALTER phonebook ALTER id ALTER 4 SET age 58;

I 'd appreciate if you could explain what I should run in terminal


Thanks in advance
Boris
Sponsored Links
    #2  
Old Unix and Linux 02-18-2016
cero cero is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 24 May 2017, 8:59 AM EDT
Posts: 451
Thanks: 4
Thanked 98 Times in 90 Posts
The mysql-documentation tells you in detail how to formulate the statment. For you example, if you'd like to change Lacatus age to 58 it would look like this:

Code:
update phonebook set age = 58 where id = 4;

The Following User Says Thank You to cero For This Useful Post:
baris35 (02-18-2016)
Sponsored Links
    #3  
Old Unix and Linux 02-18-2016
baris35 baris35 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 19 May 2017, 9:22 PM EDT
Posts: 98
Thanks: 43
Thanked 4 Times in 4 Posts
Quote:
Originally Posted by cero View Post
The mysql-documentation tells you in detail how to formulate the statment. For you example, if you'd like to change Lacatus age to 58 it would look like this:

Code:
update phonebook set age = 58 where id = 4;


Voila! It's done! Thanks for your reply Cero.
I will also check that mysql documentation for other functions.

b.regards
Boris
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SQL: Alter existing bool after printing sea Programming 3 03-05-2014 10:16 AM
my SQL Info command runnerpaul SuSE 1 06-28-2011 06:35 AM
Alter Table Shell Script ankitgupta Shell Programming and Scripting 2 10-06-2006 06:01 AM



All times are GMT -4. The time now is 05:37 PM.