· MySQL中不分大小写
· MySQL中分为DML(数据操作语言) 和 DDL(数据定义语音)
DML(数据操作语言):
SELECT - 从数据库表中获取数据
UPDATE - 更新数据库表中的数据
DELETE - 从数据库表中删除数据
INSERT INTO - 向数据库表中插入数据
DDL(数据定义语言):
CREATE DATABASE - 创建新数据库
ALTER DATABASE - 修改数据库
CREATE TABLE - 创建新表
ALTER TABLE - 变更(改变)数据库表
DROP TABLE - 删除表
CREATE INDEX - 创建索引(搜索键)
DROP INDEX - 删除索引
用例子记录
1.SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC; (order by 不需要and/or)
2.INSERT (...) VALUES (...);
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
3.NULL(总是用is)
SELECT * FROM CUSTOMERS WHERE ADDRESS IS NOT NULL
4.UPDATE(TABLE_NAME)
SET(ContactName = 'Alfred Schmidt', City = Frankfurt'),
WHERE CustomerID = 1;
5.DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
6.Select TOP 3 * FROM Customers
WHERE Country = 'Germany';
或者
Select * FROM Customers
WHERE Country = 'Germany'
LIMIT 3;
7.Select TOP 50 PERCENT * FROM Customers
8.SELECT MAX(Price)
FROM table_name
WHERE condition;
9.(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
例子看这个
https://www.cnblogs.com/lijingran/p/9001302.html

select * from A //以A为准
left join B
on A.aID = B.bID
select * from A //以B为准
right join B
on A.aID = B.bID
select * from A // 两个都是
innerjoin B
on A.aID = B.bID
网友评论