
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL insert a value to specific row and column
Let us first create a table −
mysql> create table DemoTable1569 -> ( -> StudentId varchar(10), -> StudentName varchar(20) -> ); Query OK, 0 rows affected (3.05 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1569 values('John_12','John Smith'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1569 values('David_321','Carol Taylor'); Query OK, 1 row affected (0.50 sec) mysql> insert into DemoTable1569 values('David_989','David Miller'); Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1569;
This will produce the following output
+-----------+--------------+ | StudentId | StudentName | +-----------+--------------+ | John_12 | John Smith | | David_321 | Carol Taylor | | David_989 | David Miller | +-----------+--------------+ 3 rows in set (0.00 sec)
Here is the query to insert a value to specific row and column.
mysql> update DemoTable1569 set StudentId='Carol_321' where StudentName='Carol Taylor'; Query OK, 1 row affected (0.26 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again.
mysql> select * from DemoTable1569;
This will produce the following output
+-----------+--------------+ | StudentId | StudentName | +-----------+--------------+ | John_12 | John Smith | | Carol_321 | Carol Taylor | | David_989 | David Miller | +-----------+--------------+ 3 rows in set (0.00 sec)
- Related Articles
- Swap a specific column value in MySQL
- Get only a single value from a specific MySQL row?
- Fetch a specific column value (name) in MySQL
- How to insert DATE into a MySQL column value using Java?
- MySQL: Insert a row and get the content?
- Insert NULL value into INT column in MySQL?
- Replace only a specific value from a column in MySQL
- Fetch the first letter of a column value and insert it in another column with MySQL
- MySQL CONCAT a specific column value with the corresponding record
- Select a specific value between two column values in MySQL?
- MySQL query to insert row with date?
- Place a specific value for NULL values in a MySQL column
- Insert Euro and Dollar symbol to a column in MySQL?
- MySQL query to select one specific row and another random row?\n
- Count the same value of each row in a MySQL column?

Advertisements