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 中 寫入包括 數字/字符串/變量等。

相關文章
相關標籤/搜索