Continually Improving.... let us know how support@devdiamond.net Sign in | Sign up
home articles news blog forum  

 
 


 
Skip Navigation LinksHome > Article > SQL Basics :: And, Or and Order By
SQL Basics :: And, Or and Order By
Abstract :
To add two parameter to any of the SQL Statements, you would use And, Or. You also can order your recordset by using the Order By.

Views : 2759
Published : Monday, January 21, 2002
By
HyperLink

Avarage Rating :
Page Page 1 of 1

Using the And keyword you can increase or narrow the range of your search:

SELECT * FROM CustomerTable WHERE lname LIKE 'S%' AND fname = 'Bill'

The above query would give you all records where lname starts with 'S' and that have a fname equal to 'Bill'.

     Using the Or keyword you can also increase or narrow the range of your search:

SELECT * FROM CustomerTable WHERE lname LIKE 'S%' OR lname LIKE 'B%'

This query would give you all records where lname starts with 'S' OR 'B'.

     Using the Order By keywords you can order your records output by a certain column. You can order by ascending or descending. Ascending ordering is the default.

Syntax:

SELECT * FROM TableName ORDER BY ColumnName DESC

The above code orders the results by ColumnName in descending order. To specify the order by ascending order replace 'DESC' with 'ASC'. You can also order by more than one column name. To do this simply specify the additional column names after the first one separated by a comma.


About Author

        Yasir Send Feedback
        Yasir is a .NET expert, with over 5 years experience in Microsoft Technologies, 8 years overall programming experience, he is the owner, founder & primary contributor of Minwar.com, and he also works as IT Director in the hospitality industry.