Get specific value of cell in MySQL


Let us first create a table −

mysql> create table DemoTable
(
   Name varchar(40),
   Score int
);
Query OK, 0 rows affected (0.72 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values('Chris Brown',78);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('John Doe',88);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Carol Taylor',98);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('David Miller',80);
Query OK, 1 row affected (0.68 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+--------------+-------+
| Name         | Score |
+--------------+-------+
| Chris Brown  |    78 |
| John Doe     |    88 |
| Carol Taylor |    98 |
| David Miller |    80 |
+--------------+-------+
4 rows in set (0.00 sec)

Following is the query to get specific value of cell −

mysql> select Score from DemoTable where Name='Carol Taylor';

This will produce the following output −

+-------+
| Score |
+-------+
|    98 |
+-------+
1 row in set (0.00 sec)
raja
Published on 07-Oct-2019 16:08:53
Advertisements