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_Id | FirstName | LastName | City | Marks |
---|---|---|---|---|
1 | Gautam | Gambhir | Delhi | 90 |
2 | Vijay | Chauhan | Mumbai | 59 |
3 | Mac | Henry | Washington | 67 |
4 | Sharman | Joshi | Pune | 82 |
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_Id | FirstName | LastName | City | Marks |
---|---|---|---|---|
1 | Gautam | Gambhir | Delhi | 90 |
4 | Sharman | Joshi | Pune | 82 |
Note : Semicolon at the end of SQL Statement
If we are using MS Access and SQL Server 2000 then providing semicolon after each SQL statement is optional.
(*) We are not looking for creating a table in this chapter. This chapter only provide the quick introduction to SQL syntax.