Sql Tutorial Class


sql query select statment

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 NameProduct CompanyDescriptionPriceQuantityProduct Country
Samsung MobileSamsung CompanySamsung Mobile$501000South Korea
Samsung Smart PhoneSamsung CompanySamsung Mobile$80500South Korea
Apple iPhoneApple CompanyApple iPhone$100800USA
Apple LaptopApple CompanyApple Laptop$2001500USA
Sony CameraCony CompanySony Camera$1001200Japan
Cooking PotChina CompanyChina Cooking$401000China




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