1、MySQL 为关系型数据库(Relational Database Management System), 这种所谓的”关系型”可以理解为”表格”的概念, 一个关系型数据库由一个或数个表格组成
2、sql语句:
SELECT * FROM sdb_link
SELECT link_id FROM sdb_link
SELECT * FROM sdb_link where link_name=’外贸’ //WHERE 用于选择规定选择的标准
WHERE 操作符 > 、<、 = 、<> 、>= 、<=、BETWEEN、LIKE
SELECT DISTINCT orderlist FROM sdb_link //DISTINCT 用于返回唯一不同的值
SELECT * FROM Persons WHERE FirstName=’Thomas’ AND
LastName=’Carter’ //AND 条件都符合
SELECT * FROM Persons WHERE firstname=’Thomas’ OR
lastname=’Carter’ // OR 只要有一个条件符合
SELECT Company, OrderNumber FROM Orders ORDER BY Company //ORDER BY 语句用于根据指定的列对结果集进行排序。DESC 倒序 ASC 顺序
INSERT INTO sdb_link VALUES (104, 17, ‘测试17’, ‘http://www.baidu.com’,”,17,true,”,”,1) //INSERT INTO 插入数据
INSERT INTO Persons (Lastname,Address) VALUES(‘Wilson’,’Champs-Elysees’)
UPDATE Person SET FirstName = ‘Fred’ WHERE LastName = ‘Wilson’ //UPDATE 更新一条数据
CREATE TABLE Persons(Id_P int,LastName varchar(255),FirstName varchar(255),Address varchar(255),City varchar(255))
DELETE FROM Person WHERE LastName = ‘Wilson’ //DELETE 删除一条数据
SELECT * FROM sdb_link LIMIT 5
SELECT * FROM sdb_link WHERE link_id IN (1,2,5,6)
SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2
SELECT link_id AS ID, link_name AS Name FROM sdb_link //AS
SELECT sdb_link.link_id,sdb_jpush.id FROM sdb_link,sdb_jpush //查询多张表信息
SELECT sdb_link.link_id,sdb_jpush.id FROM sdb_link,sdb_jpush WHERE sdb_link.link_id=sdb_jpush.id
SELECT sdb_link.link_id,sdb_jpush.id FROM sdb_link INNER JOIN sdb_jpush ON sdb_link.link_id = sdb_jpush.id
SELECT sdb_link.link_id,sdb_jpush.id FROM sdb_link LEFT JOIN sdb_jpush ON sdb_link.link_id = sdb_jpush.id //LEFT JOIN 关键字会从左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中没有匹配的行
SELECT sdb_link.link_id,sdb_jpush.id FROM sdb_link RIGHT JOIN sdb_jpush ON sdb_link.link_id = sdb_jpush.id //RIGHT JOIN 关键字会从右表 (table_name1) 那里返回所有的行,即使在左表 (table_name2) 中没有匹配的行
SELECT column_name(s) FROM sdb_link UNION SELECT column_name(s) FROM sdb_jpush //UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条 SELECT 语句中的列的顺序必须相同
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons FULL JOIN Orders ON Persons.Id_P=Orders.Id_P ORDER BY Persons.LastName // FULL JOIN 全连接
3、sql 函数
最新评论