1. 程式人生 > >SQL語言的增刪改查

SQL語言的增刪改查

刪除 bob show into lec eat reat 註入 ike

select(查), update(改), delete(刪), insert into(增) select * from table_name 獲取表中所有字段 select id, name, sex from table_name 獲取表中的id,name,sex字段 select count(id) count from table_name 獲取表中列表總數量 count(*/1/id 都行) 第二個count是作為別名 select * from table_name limit 0, 10 分頁 select * from table_name where id = 1 獲取id為1的數據 select * from table_name where id = 1 and name=‘Job‘ 獲取id為1 name為Job的數據 並聯條件用and連接 select * from table_name where name LIKE ‘%Job%‘ 模糊查詢 select * from table_name where create_time between ‘${startTime}‘ and ‘${endTime}‘ order by create_time DESC 選擇時間範圍 按照逆序排 update table_name set age = 18 where id = 1 根據id修改一條數據 update table_name set age = 18 where id != 1 根據id修改多條數據 update table_name set age = 18 where id in (1, 2, 3) 根據id修改多條數據 update table_name set show = 0 where id != 1;update table_name set show = 1 where id = 1 只有id為1的數據show為1 其余為0。兩條語句用分號隔開(大神說sql語句不要寫兩條:1.版本不兼容 2.不安全,會有sql註入的危險) delete from table_name where id = ? 刪除一條數據 insert into table_name (name, age, create_time) values (‘Bob‘,18,now()) 插入一條數據 insert into table_name (name, age, create_time) values (‘Bob‘,18,now()),(‘Jack‘,20,now()) 插入多條數據

SQL語言的增刪改查