sql语句学习
CONCAT 连接字符串或字段
AS 起别名
执行顺序:FROM,WHERE,SELECT,ORDER BY
INSERT INTO
UPDATE SET
SELECT FROM
字符串和日期要用单引号括起来
区分大小写(BINARY): WHERE BINARY product_name='gx8'
WHERE 300<=price<=400 表示price>=300 OR price<=400
WHERE product_id IN (2,3,4,6,7,8) NOT IN
WHERE price IS NULL IS NOT NULL
%:表示任意个字符
_:表示一个字符
WHERE name LIKE '%gx_'
ORDER BY price ASC DESC 其中ASC为默认
ORDER BY price ASC ,id DESC
LIMIT ?,?
第一个?表示本页,开始索引(从0开始)beginIndex
第二个?表示每页显示的条数pageSize
beginIndex = (currentPage-1)*pageSize
COUNT 统计结果记录数
MAX 统计计算最大值
MIN 统计计算最小值
SUM 统计计算求和
AVG 统计计算平均值
SELECT AVG(price) FROM product
SELECT COUNT(1) FROM product
SELECT classify_id,AVG(price) FROM product GROUP BY classfy_id
关联查询,即表与表连接起来进行查询
共21条
共24条
共21条
逆天改命!我命由我不由天!