SQL SYNTAX

这篇博客总结了SQL语言的主要语法,包括SELECT、DISTINCT、WHERE、ORDER BY、INSERT INTO、NULL值处理、UPDATE、DELETE、聚合函数、LIKE操作符、JOIN类型、UNION、GROUP BY、HAVING、EXISTS、ANY和ALL操作符以及CASE语句等内容。
摘要由CSDN通过智能技术生成

SQL SYNTAX

Reference:本文大部分是对w3c网站的教程的总结

  • SQL SELECT
select Column
select *
  • SQL SELECT DISTINCT
select distinct
select COUNT(distinct column_name)
  • SQL WHERE

where clause

  • SQL AND,OR AND NOT Operators
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
  • SQL ORDER BY
    ASC:ascending/
    DESC:descending
order by
order by desc
order by several column
SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC;
  • SQL INSERT INTO
INSERT INTO

If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query.

INSERT INTO table_name
VALUES (value1, value2, value3, ...)

Insert Data Only in Specified Columns

The following SQL statement will insert a new record, but only insert data in the “CustomerName”, “City”, and “Country” columns (CustomerID will be updated automatically):

INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway');
  • SQL NULL Values

We will have to use the IS NULL and IS NOT NULL operators instead.

S
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值