Also
This SQL is used to execute queries on databases.
Select CustomerName,Age from Customers where
Age>35 orderby CustomerName
Join Type | Description | Syntax |
Inner Join | Joins the columns of one table to the columns of another table only for rows that meet the specified condition | Select [Colums] from [Table1]
INNER JOIN [Table2] ON [Join Condition] |
Left Outer Join | Includes all rows from the left table and joins table2 column where the condition is meet, or returns NULLS in place of the unmatched column if the condiditon isn't met | Select [Colums] from [Table1]
LEFT OUTER JOIN [Table2] ON [Join Condition] The 'outer' key word can be ommited |
Right Outer Join | All the rows from the right hand table are included, with nulls if the condition isn't meet | Select [Colums] from [Table1]
RIGHT OUTER JOIN [Table2] ON [Join Condition] The 'outer' key word can be ommited |
Full Outer Join | Every Rows from both tables will have a corresponding row in the results. Where the condition is not met, the unmatched rows will be NULL | Select [Colums] from [Table1]
RIGHT OUTER JOIN [Table2] ON [Join Condition] The 'outer' key word can be ommited |
Cross Join | Every row of the left table will be combined with every row of the right table. No join condition is required however the results can be filtered using the select's where clause to reduce the row count. | Select [Colums] from [Table1]
CROSS JOIN [Table2] -or- Select [Columns] From Table1,Table2 |
INSERT statements are used to add rows
to a table. Identity fields in the inserted record and NOT returned
(which is just stupid as all hell) but can be retrieved by using SELECT
@@IDENTITY; or SELECT SCOPE_IDENTITY() in 2005. Watch out for
automatic triggers as they may cause the wrong identity to be returned. See
Inserting records in ASP with
ADO
DELETE is used to remove rows from a table
DELETE FROM table WHERE
deletefilter
The UPDATE statement is used to change rows already entered into a table
UPDATE table SET
column = expression,column =
expression WHERE updatefilter
The update filter can specifiy a single row (e.g where id=10034) or multiple rows (e.g. where id > 10000) to be updated
Is a combination of one or more predicates using the logical operators AND, OR, and NOT.
<search_condition> ::=
{ [ NOT ] <predicate>
| ( <search_condition> ) }
[ {AND | OR} [NOT]
{<predicate> | ( <search_condition> ) } ]
} [,...n]
<predicate> ::=
{
expression { = |
<> | != | > | >= | !> | < | <= | !< }
expression
| string_expression
[NOT] LIKE string_expression
[ESCAPE
'escape_character']
| expression [NOT]
BETWEEN expression AND expression
| expression IS [NOT]
NULL
| CONTAINS
( {column
| * }, '<contains_search_condition>' )
| FREETEXT (
{column | * }, 'freetext_string' )
| expression [NOT]
IN (subquery | expression
[,...n])
| expression { = |
<> | != | > | >= | !> | < | <= | !< }
{ALL
| SOME | ANY} (subquery)
| EXISTS
(subquery)
}
The order of precedence for the logical operators is NOT (highest), followed by AND, followed by OR. The order of evaluation at the same precedence level is from left to right. Parentheses can be used to override this order in a search condition. For information about how the logical operators operate on truth values, see AND, OR, and NOT.
This example assumes a description column exists in finances table. To search for the rows in which the description column contains the exact characters g_, use the ESCAPE option because _ is a wildcard character. Without specifying the ESCAPE option, the query would search for any description values containing the letter g followed by any single character other than the _ character.
SELECT *
FROM finances
WHERE description LIKE 'gs_' ESCAPE 'S'
GO
This example uses the WHERE clause to retrieve the contact name, telephone, and fax numbers for any companies containing the string snabbköp at the end of the company name.
USE Northwind
SELECT CompanyName, ContactName, Phone, Fax
FROM Customers
WHERE CompanyName LIKE N'%snabbköp'
ORDER BY CompanyName ASC, ContactName ASC
file: /Techref/language/sql/transact.htm, 17KB, , updated: 2017/8/7 08:26, local time: 2024/11/13 02:21,
18.119.103.132:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/language/sql/transact.htm"> Microsoft SQL Server, Transact SQL, T-SQL</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.