Sql Select Statement:
Sql Select Statement: Select statement is very important on sql query. Every sql query statement you need select statement. For retrieving values/data from sql database you need to use select statement.
How to use select statement in sql query. Read the given syntax
Syntax: Select [column name]/[*] from [Table-Name]
Description of Sql select statement
select: is an sql statement. [like "=" sign on maths]
[column name]= Field name. Ex. Name, Address, Phone......
Or[*]: =Indicates all field name.
from: is part of sql select statement. Where user wants to get data.
[Table-Name]: Indicate the name of table where data is stored.
Example: Here is a table
Table Name is: ItemDetails
Product Name | Product Company | Description | Price | Quantity | Product Country |
---|---|---|---|---|---|
Samsung Mobile | Samsung Company | Samsung Mobile | $50 | 1000 | South Korea |
Samsung Smart Phone | Samsung Company | Samsung Mobile | $80 | 500 | South Korea |
Apple iPhone | Apple Company | Apple iPhone | $100 | 800 | USA |
Apple Laptop | Apple Company | Apple Laptop | $200 | 1500 | USA |
Sony Camera | Cony Company | Sony Camera | $100 | 1200 | Japan |
Cooking Pot | China Company | China Cooking | $40 | 1000 | China |
Now: How to use Sql query select statement?
1. If you want to get ProductName and Price data from above table.
Select ProductName, Price From ItemDetails
Now, your result will be:
Product Name | Price |
Samsung Mobile | $50 |
Samsung Smart Phone | $80 |
Apple iPhone | $100 |
Apple Laptop | $200 |
Sony Camera | $100 |
Cooking Pot | $40 |
2. If you want to get ProductName, Quantity and ProductCountry then
Select ProductName, Quantity, ProductCounry From ItemDetails
Now, result will be:
Product Name | Price | Product Country |
Samsung Mobile | $50 | South Korea |
Samsung Smart Phone | $80 | South Korea |
Apple iPhone | $100 | USA |
Apple Laptop | $200 | USA |
Sony Camera | $100 | Japan |
Cooking Pot | $40 | China |
No comments:
Post a Comment