榜首部分 INSERT SELECT UPDATE DELETEITeye - 乐橙lc8

榜首部分 INSERT SELECT UPDATE DELETEITeye

2019年03月25日14时55分53秒 | 作者: 星鹏 | 标签: 能够,子句,这儿 | 浏览: 499

!EndFragment

* 即使 DATETIME 和 TIMESTAMP 回来相同的格局,它们的工作方式很不同。在 INSERT 或 UPDATE 查询中,TIMESTAMP 主动把本身设置为当时的日期和时刻。TIMESTAMP 也承受不同的格局,比方 YYYYMMDDHHMMSS、YYMMDDHHMMSS、YYYYMMDD 或 YYMMDD。

 

三、INSERT句子

INSERT INTO my_contacts # 省掉列名,数据悉数填入
VALUES
(ZhangSan,F,1990-09-09,13513513513,My Best Friend!);
INSERT INTO my_contacts # 省掉部分列名
(name,gender,phone)
VALUES
(LiSi,F,15815815815);
INSERT INTO my_contacts # 能够改动列的次序
(name,gender,phone,birthday,information)
VALUES
(WangEr,M,18218218218,1991-05-05,A Lovely Person!);

 四、SELECT句子

SELECT * FROM my_contacts
SELECT * FROM my_contacts WHERE name = ZhangSan; #一般除数字外,其他的值都要用引号
SELECT * FROM my_contacts WHERE name hello; #按字典次序做巨细比较
SELECT * FROM my_contacts WHERE year=20;
SELECT drink_name,price,rating FROM drink WHERE price #运算符号有 , , ,=, =, =
SELECT drink_name FROM drink WHERE price 3 AND rating 
SELECT drink_name FROM drink WHERE price 3 OR rating 
SELECT * FROM my_contacts WHERE name M AND name =D; #查询首字母在D和M之间的name
SELECT drink_name FROM drink WHERE rating IS NULL; #挑选rating是空的值
SELECT * FROM my_contacts WHERE name LIKE %San;
SELECT * FROM my_contacts WHERE name = _San; #只要一个匹配
SELECT drink_name FROM drink WHERE price BETWEEN 2 AND 4;
SELECT drink_name FROM drink WHERE interest IN(good,pretty goog,wonderful);
SELECT drink_name FROM drink WHERE NOT price BETWEEN 2 AND 4; 
 #NOT可与BETWEEN、LIKE、NULL一重用,一般在WHERE后边
SELECT * FROM my_contacts WHERE NOT name LIKE %San AND NOT name LIKE %Jan;

 五、DELETE

 

    DELETE能够用于删去一行或许多行,依据Where子句而定,这儿的Where子句跟SELECT中的Where子句用法彻底相同。如上面呈现的LIKE、IN、BETWEEN,这儿都能够用。

DELETE FROM my_contacts;
DELETE FROM my_contacts WHERE name=ZhangSan;
DELETE FROM my_contacts WHERE name=ZhangSanAND year=20;

 六、UPDATE

 

UPDATE my_contacts
SET gender= F;
WHERE name = ZhangSan;
UPDATE my_contacts
SET gender= F,years=20;
WHERE gender= M AND years=21;
UPDATE my_contacts #这儿能够套用根本运算,如+、-、*、/
SET years=years+1;
WHERE gender= F;

 七、单引号的处理

 

SELECT * FROM my_contacts WHERE name=Grover\s Mill;
SELECT * FROM my_contacts WHERE name=Grovers Mill;

 

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表乐橙lc8立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1
  • 2
  • 3

    Oracle Index 的三个问题ITeye

    索引,运用,数据
  • 4

    检查sqlserver的端口号ITeye

    端口号,能够,看到
  • 5
  • 6

    oracle中userITeye

    字段,运用,数据
  • 7
  • 8
  • 9

    mysql一切指令ITeye

    指令,用户,数据库
  • 10