SQL Syntax



In this chapter we are going to write simple query to understand the SQL Syntax. Consider the following table on which we are triggering the query. Table name is “Student”.

S_IdFirstNameLastNameCityMarks
1GautamGambhirDelhi90
2VijayChauhanMumbai59
3MacHenryWashington67
4SharmanJoshiPune82

Table contain the 5 fields (i.e S_Id,FirstName,LastName,City,Marks) and 4 records.

Example Query : 1

We have already created table[*] and we need to filter the above table by firing one simple SQL query. Consider following simple SQL query. –

SELECT * FROM Students;

Example Query : 2

Another query example to select only records having marks greater than 80 –

SELECT * FROM Students where Marks > 80;

after executing this query output generated will be like this –

S_IdFirstNameLastNameCityMarks
1GautamGambhirDelhi90
4SharmanJoshiPune82

Note : Semicolon at the end of SQL Statement

[box]If we are using MS Access and SQL Server 2000 then providing semicolon after each SQL statement is optional.[/box]

[box style=”blue info rounded shadow”](*) We are not looking for creating a table in this chapter. This chapter only provide the quick introduction to SQL syntax.[/box]