SQL命令:向表中插入數據,查詢表中的數據


向表中插入數據

  • 插入一行數據
insert into 表名(字段1,字段2,字段3) values(數值1,數值2,數值3);
  • 插入多行數據
insert into 表名(字段1,字段2,字段3) values(數值1,數值2,數值3),(數值4,數值5,數值6),(數值7,數值8,數值9);

查詢表中的數據

  • 查詢tab01表中,id=1數據
select * from tab01 where id=1;
  • 查詢tab01表中,id字段中包含1的數據
select * from  tab01 where id like '%1%';
  • 查詢tab01表中,id字段中包含1的數據,按id降序排序
select * from tab01 where id like '%1%' order by id desc;
  • 查詢tab01表中,id字段中包含1的數據,按id升序排序
select * from tab01 where id like '%1%' order by id asc;
  • 查詢tab01表中,id字段中包含1的數據,按id降序排序,取id最大的三個數據
select * from tab01 where id like '%1%' order by id desc limit 3;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM