2023-03-27 MySQL基本語句二

數(shù)據(jù)行操作的相關SQL語句(指令)如下:

  • 數(shù)據(jù)

    insert into 表名 (列名,列名,列名) values(對應列的值,對應列的值,對應列的值);
    
    insert into tb1(name,password) values('武沛齊','123123');
    insert into tb1(name,password) values('武沛齊','123123'),('alex','123');
    
    insert into tb1 values('武沛齊','123123'),('alex','123'); -- 如果表中只有2列
    
  • 除數(shù)據(jù)

    delete from 表名;
    delete from 表名 where 條件;
    
    delete from tb1;
    delete from tb1 where name="wupeiqi";
    delete from tb1 where name="wupeiqi" and password="123";
    delete from tb1 where id>9;
    
  • 數(shù)據(jù)

    update 表名 set 列名=值;
    update 表名 set 列名=值 where 條件;
    
    update tb1 set name="wupeiqi";
    update tb1 set name="wupeiqi" where id=1;
    
    update tb1 set age=age+1;  -- 整型
    update tb1 set age=age+1 where id=2;
    
    update L3 set name=concat(name,"db");
    update L3 set name=concat(name,"123")  where id=2;  -- concat一個函數(shù),可以拼接字符串
    
  • 詢數(shù)據(jù)

    select * from 表名;
    select 列名,列名,列名 from 表名;
    select 列名,列名 as 別名,列名 from 表名;
    select * from 表名 where 條件;
    
    select * from tb1;
    select id,name,age from tb1;
    select id,name as N,age, from tb1;
    select id,name as N,age, 111 from tb1;
    
    select * from tb1 where id = 1;
    select * from tb1 where id > 1;
    select * from tb1 where id != 1;
    select * from tb1 where name="wupeiqi" and password="123";
    
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容