您是第免费计数器位访客

PHP写数据库基本语法

<div>
<div>insert into 表名 value(null,字段1的值,字段2的值,字段3的值,....)</div>
<div>delete from 表名 where id = 你要删除的id的值</div>
<div>update 表名 set 字段1 = 字段1的值,字段2=字段2的值,字段3=字段3的值 .... where id = 你要修改的id的值</div>
<div>select * from 表 #查询所有</div>
<div>select * from A inner join B where A.公共字段 = B.公共字段 and 条件 #多表联合查询</div>
<div># 条件查询</div>
<div>select * from 表名 where 条件</div>
<div># 查询性别为男的</div>
<div>select * from student where gender = '男'</div>
<div># 查询年龄大于30岁的</div>
<div>select * from student where age &gt;= 30;</div>
<div># 查询年龄在25岁到28岁之间</div>
<div>select * from student where age &gt;=25 and age &lt;= 28</div>
<div># 排序 Order by</div>
<div>select * from student order by age asc #从小到大的排序</div>
<div>select * from student order by age desc # 从大到小的排序</div>
<div># 模糊查询 like '% x %'</div>
<div>select * from student where name like '%三%'</div>
<div>select * from student where name like '%章%'</div>
<div># 分页 limit</div>
<div>select * from student limit 0,5;# 从索引从0到5的数据 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1</div>
<div>select * from student limit 5,5# 从索引从6到10的数据</div>
<div>select * from student limit 10,5# 从索引从10到15的数据</div>
<div>select * from student limit n,m &nbsp; # 从索引n开始,获取m条数据</div>
<br />
<div># 一页显示5条</div>
<div>select * from student limit (1-1)*5,5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1</div>
<div>select * from student limit (2-1)*5,5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2</div>
<div>select * from student limit (3-1)*5,5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3</div>

<br />
<div>前端至少传入两个数 当前页数 x,一页显示多少条 y</div>
<div>select * from student limit (x-1)*y,y</div>
<div>select * from student limit (3-1)*5,5</div>

</div>
<br/>
<div>查询表单共有多少条数据</div>
<div>select count(*) from menu </div>

posted @ 2022-06-26 19:36  前端司令  阅读(45)  评论(0编辑  收藏  举报