2017-3-10 SQL Server T-SQL statement advanced query

Source: Internet
Author: User

Conditional modification:
Update table name set column name = value where column name = value
Conditional Delete:
Delete from table name where column name = value
Advanced Query
Conditional query
Check column * Instead of columns to view, comma separated by multiple columns
Filter criteria where column name = >= <= > < value and OR
Fuzzy query
SELECT * FROM table name where column name like '% value% '% wildcard
Sort queries
SELECT * FROM table name where order by column name Asc/desc
Go to re-query
Select DISTINCT column name from table name
Group queries
Select a column name from table name GROUP by
Sub-query
Use a query statement as a value

ALTER TABLE FOREIGN KEY table name add constraint constraint name foreign key (foreign key field) references primary key table name (constraint column name)

If the IDs in table A are primary keys, to constrain the aid column in table B, then the statement should be:

ALTER TABLE B add constraint a_b_ids foreign key (Aid) references A (IDS)

2017-3-10 SQL Server T-SQL statement advanced query

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.