1. 程式人生 > >基礎sql語句

基礎sql語句

查詢

基礎

SELECT `fileID` FROM `task` WHERE `id`= 1

內範圍查詢 多條件查詢

// 並排序
SELECT * FROM `update` WHERE `nowstate`=2 AND `note` is NOT NULL AND (`time` > 1) AND (`time` < 10) order by `time` desc

查詢完成重新命名欄位名 as

SELECT `id`,`fileID`,`note`,from_unixtime(`createTime`) as createTime FROM `task` WHERE `updataType`=2  ORDER BY `createTime` DESC

新增

INSERT INTO `task` (`fileID`,`note`,`createTime`,`欄位`) VALUES ('值', '值', '值',1)

修改

UPDATE `update` SET `nowstate`=2 WHERE (`id`=1)

刪除

DELETE FROM `表名稱` WHERE `列