Breaking News

Reading Data from a Table

Reading Data from a Table To read data in SQL, you create a query using the SELECT statement.
To retrieve a list of all the data in the Course table, use:

mysql > SELECT * from Course;

Output

Course id Course name Duration
1 C 3
2 ASP.NET 6
3 MySql 8

3 rows in set

The asterisk means you need “all fields” .You can also specify just the field or fields you want to retrieve:

mysql > SELECT Course name from Course;

Output

Course name
C
ASP.NET
MySql

3 rows in set 

To retrieve a selected row or rows, you need to use a WHERE clause at the end of the SELECT statement. A WHERE clause filters the results according to the condition in the clause. You can use any expression in a WHERE condition.

Here is a simple example of WHERE clauses

mysql > SELECT * from Course WHERE Course name = ‘ASP.NET’;

Output

Course id Course name Duration
2 ASP.NET 6

1 row in set 

mysql > SELECT * from Course WHERE Duration id > = 6;

Output

Course id Course name Duration
1 C 3
2 ASP.NET 6

2 rows in set