Saturday 23 July 2016

Get specific fields from table



SELECT * FROM table_name;
Above statement gives you all the contents of given table.

mysql> SELECT * FROM employee;
+----+--------------+---------------+---------------------+
| id | name         | mailId        | dateOfBirth         |
+----+--------------+---------------+---------------------+
|  1 | Hari Krishna | hari@hari.com | 1989-05-06 07:30:00 |
|  2 | Gopi         | gopi@gopi.com | 1987-11-06 17:30:00 |
|  3 | PTR          | ptr@ptr.com   | 1988-06-06 23:30:00 |
|  4 | Rama Krishna | rama@rama.com | 1988-11-06 03:54:00 |
+----+--------------+---------------+---------------------+
4 rows in set (0.00 sec)


Get specific fields information
SELECT (column1, column2 ....columnN) FROM table_name;
              
Above statement return specific fields information.

mysql> SELECT name, dateOfBirth FROM employee;
+--------------+---------------------+
| name         | dateOfBirth         |
+--------------+---------------------+
| Hari Krishna | 1989-05-06 07:30:00 |
| Gopi         | 1987-11-06 17:30:00 |
| PTR          | 1988-06-06 23:30:00 |
| Rama Krishna | 1988-11-06 03:54:00 |
+--------------+---------------------+
4 rows in set (0.00 sec) 




Previous                                                 Next                                                 Home

No comments:

Post a Comment