CREATE TABLE `member` ( `uid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` char(255) NOT NULL, `pass` char(255) NOT NULL, `token` char(255) NOT NULL, `src_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '来源id', PRIMARY KEY (`uid`,`name`))INSERT INTO Persons (LastName) VALUES ('Wilson')UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson' DELETE FROM Person WHERE LastName = 'Wilson'SELECT DISTINCT Company FROM OrdersSELECT * FROM member LIMIT 5SELECT * FROM member WHERE NAME LIKE '%e_a%'SELECT * FROM member WHERE NAME IN ('zen','test')SELECT * FROM member WHERE uid BETWEEN '4' AND '11'SELECT member.`name`,user_data.`nickname` FROM member,user_data WHERE member.`uid`= user_data.`uid`SELECT NAME FROM member UNION SELECT nickname FROM user_data SELECT * FROM tablea INNER JOIN tableb ON tablea.name = tableb.nameSELECT AVG(uid) AS uidAvg FROM memberSELECT COUNT(uid) AS uidAvg FROM member 计数SELECT SUM(uid) AS uidAvg FROM member 总数在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用。SELECT rid,SUM(zdl) FROM sys_hero WHERE rid < 20000000 GROUP BY rid HAVING SUM(zdl) >7800 LIMIT 0,10