MYSQL 基本语句

1.update测试

update table1,table2,table3字符串

set table1 = 1table

where table1.id = table2.clum变量

and table2.id = table3.clum;date

注:在更新某条记录的字段,而且该记录没法直接拿到,与其余表有关联,那么须要将全部的关联表(WHERE 条件中的表)写到 UPDATE 的后面。tab

2.SELECT字符

SELECT IF(`status` = 1 ,1,0) AS S FROM table1 WHERE `status` != 2;数字

在SQL语句中进行判断,IF(`status` = 1 ,1,0) : 若是 `status` 为 1 ,给 1 ;若是不为 1 ,给 0。ab

3.INSERT
INSERT INTO table(`id`,`name`,`year`,`money`)

SELECT `id`,'测试',1,`money`

FROM table2 WHERE `status` != 0;

多条记录插入,能够在SELECT 中 写入包括 数字/字符串/变量等。

相关文章
相关标签/搜索