Let us first create a table −
mysql> create table DemoTable1837 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1837(StudentName) values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Bob'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Mike'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1837;
This will produce the following output −
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 1 | Chris | | 2 | David | | 3 | Bob | | 4 | Mike | +-----------+-------------+ 4 rows in set (0.00 sec)
Here is the query to get a specific column records:
mysql> select StudentName from DemoTable1837;
This will produce the following output −
+-------------+ | StudentName | +-------------+ | Chris | | David | | Bob | | Mike | +-------------+ 4 rows in set (0.00 sec)