PHP之Mysql常用SQL语句示例的深入分析
2023-06-13 09:15:00 时间
1.插入数据
insertinto表名(列名1,列名2,列名..)values(值1,值2,值...);
insertintoproduct(name,price,pic_path)values("Nike",500,"uploads/3245.jpg");
2.更新数据
update表名set列名1=值1,列名2=值2[where条件];
updateproductsetname="LiNing",price=50whereid=2;
3.删除数据
deletefrom表名[where条件];
deletefromproductwhereid=2;
4.查询所有数据
select*from表名;select*fromproduct;
5.查询部份列
select列名1,列名2,列名Nfrom表名;
selectname,pricefromproduct;
6.条件查询
#比较=,<,>,<=,>=,!=
select*from表名where列名=值;
select*fromproductwhereid=2;
#and与
select*from表名where条件1and条件2and条件N;
select*fromproductwherename="Nike"andprice=50;
#or或
select*from表名where条件1or条件2or条件N;
select*fromproductwherename="Nike"orprice>50;
#not非
select*from表名wherenot条件