Wednesday 1 October 2014

View data in table

Use SELECT statement, select and display the records from table.

Syntax
SELECT column1, column2, columnN FROM table_name;

1. To select ids from employee table
mysql> select id from employee;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

2. To select id, salary from employee table
mysql> select id,salary from employee;
+----+--------+
| id | salary |
+----+--------+
|  1 | 100000 |
|  2 |  50000 |
|  3 |  25000 |
+----+--------+
3 rows in set (0.00 sec)

3. To select all the records from employee table.
mysql> select * from employee;
+----+-----------+-----------+--------+---------------------+
| id | firstName | lastName  | salary | mailId              |
+----+-----------+-----------+--------+---------------------+
|  1 | Krishna   | Ananda    | 100000 | krishna@krishna.com |
|  2 | Arjun     | Dhanunjay |  50000 | arjun@arjun.com     |
|  3 | Ptr       | Ptr       |  25000 | ptr@ptr.com         |
+----+-----------+-----------+--------+---------------------+
3 rows in set (0.00 sec)



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment