MVC

  • Home
  • HTML
    • Overview
    • Formatting
  • Java Script
    • Overview
    • Validation
  • CSS
    • Overview
  • Sql
    • Overview
    • SQL Select
    • SQL Command
    • Advance Query
    • SQL Create
    • Function
    • Function vs StoreProcedure
    • Stored Procedures
  • MVC
    • OverView
    • Evolution of MVC
    • Install VisualStudio-2015
    • Create First Application
  • LINQ
    • Introduction
  • Privacy Policy

Saturday, 4 March 2017

SQL Select

  Unknown       10:01       Select       No comments    

The SQL SELECT Statement

The SELECT statement is used to select data from a database.

SQL SELECT Syntax

SELECT column_name,column_name
FROM table_name;

Ex.
SELECT * FROM TABLE_NAME
Note - This Query select All data in table from database.

SQL SELECT DISTINCT

The SELECT DISTINCT statement is used to return only distinct (different) values.
In a table contain many duplicate values. and sometimes you only want to list the different (distinct) values.
The DISTINCT keyword can be used to return only distinct (different) values.

SQL SELECT DISTINCT Syntax

SELECT DISTINCT column_name
FROM table_name

The following SQL statement selects only the distinct values from the "Name" columns from the "Master" table:

Example

SELECT DISTINCT Name FROM Master; 

The SQL WHERE


In Sql Select Query you want to apply Where condition then use this query and give condition whatever you want to apply. like example
Syntax
SELECT column1,column2 FROM TableName WHERE column_name operator value;
Example
Select EmpName,Salary from Employe
EmpName Salary
Jeet30000
Ranu15000
Pulkit10000
Vijay12000

Note - In This Select query select EmpName & Salary column name from Employe table ,execute this query then get all EmpName and according salary in Employe table, but You want those record according particular Empname and salary based then you apply where condition. like
Example
Select EmpName,Salary from Employe where Salary > 15000
Output-
Note- Filter according where condition and get result
EmpName Salary
Jeet30000

SQL ORDER BY

Select Query and you want to sort result by one or more columns then use order by in query like in example
Syntax
SELECT column1,column2 FROM TableName ORDRE BY column_name ASC|DESC

Example
SELECT EmpName,Salary from Employe ORDER BY EmpName DESC
EmpName Salary
Vijay12000
Ranu15000
Pulkit10000
Jeet30000
Note-In this example record sort by descending ordre by EempName. if you not give DESC keyword then sorts the records in ascending order by default,

SQL AND & OR Operators


In this artical describe The AND & OR operators. This operators are used to filter records based on more than one condition. AND Operator- Apply this Operator displays a record if both the first condition AND the second condition are true.Both condition are mandatory true
Syntax
SELECT column1,column2 FROM TableName WHERE Condition1 AND condition2

Example
Select EmpName,Salary from Employe where Salary > 15000 AND Salary = 30000
Output-
Note- Filter according where condition and get result
EmpName Salary
Jeet30000
Notes - In this example both condition true salary is grater then 15000 and equal to 30000 both condition match and return result So we use and condition

OR Operator


OR Operator- Apply this Operator displays a record if either the first condition AND the second condition is true.
Example
Select EmpName,Salary from Employe where Salary > 15000 OR Salary < 40000
Output-
Note- Filter according where condition and get result
EmpName Salary
Jeet30000
Note- Apply OR condition where salary is greater then 15000 and less then 40000 and return sql result.

Combining AND & OR


You can also combine AND and OR (use parenthesis to form complex expressions).
Example
Select EmpName,Salary from Employe where EmpName='Jeet' AND (Salary > 15000 OR Salary < 40000)
Output-
Note- Filter according where condition and get result
EmpName Salary
Jeet30000
The following SQL statement selects all Employe record from the EmpName "Jeet" AND the Salary must be greater than to "15000" OR less than "40000", in the "Employe" table:
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email This BlogThis! Share to X Share to Facebook
Newer Post Older Post Home

0 comments :

Post a Comment

learningmvctutorial

Popular Posts

  • Difference Between function v/s store procedure
    Definition  of Store Procedure In a database management system (DBMS), a  stored procedure  is a set of Structured Query Language (SQL...
  • Overview of HTML
    What is HTML? First developed by Tim Berners-Lee in 1990 . HTML is used to create electronic documents (called pages) that are displ...
  • Overview
      SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
  • What is LINQ
    LINQ  (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Mic...
  • What is Function in Sql Server
    A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in...
  • About Javascript
    What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
  • Create Duplicate Table of existing table in SQL Server
    In This Tutorial we create table and want to same structure and same data then We create new table with data type after that  insert in ta...
  • Operator in JavaScript
    What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
  • SQL Select
    The SQL SELECT Statement The SELECT statement is used to select data from a database. SQL SELECT Syntax SELECT column_name , column_n...
  • Create First Application in MVC
    We want to create Firstly application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer ...

Blog Archive

  • ▼  2017 ( 35 )
    • ►  November ( 1 )
    • ►  October ( 2 )
    • ►  September ( 4 )
    • ►  August ( 1 )
    • ►  July ( 1 )
    • ►  May ( 3 )
    • ►  April ( 7 )
    • ▼  March ( 13 )
      • What Is Store Procedure
      • Create First Application in MVC
      • How To Install Visual Stdio Step by Step Process
      • Overview of CSS
      • Overview of HTML
      • What is LINQ
      • Overview
      • Difference Between function v/s store procedure
      • What is Function in Sql Server
      • How To Create DataBase & Table in SQL Server
      • SQL Select
      • Open Application in MVC
      • MVC OverView
    • ►  February ( 3 )
Powered by Blogger.

Categories

  • AdvanceQuery
  • CreateApplication
  • CreateDb
  • CssOverview
  • Evolution
  • Formatting
  • Function
  • FunctionVSSp
  • HtmlOverview
  • InstallVisualStudio
  • Introduction
  • javascriptOverview
  • JsValidation
  • Mvc-vs-Asp.Net
  • OverView
  • Select
  • SqlCommand
  • SQLOverview
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © MVC | Powered by Blogger
Design by Vibha Acharya