I want these lines to run FOR ALL of the values of my database(我希望这些行运行我数据库的所有值)
问题描述
$sql = 'SELECT * FROM t1
RIGHT OUTER JOIN t2 ON t2.wid = t1.wid
LIMIT ' . $number . ' OFFSET 678';
当我用手改变这个偏移量时,它会针对我的数据库的不同值运行......我怎么能在不改变我的手这个偏移量的情况下做到这一点?有人说我可以在没有偏移的情况下做到这一点,但他没有告诉我如何......有人可以帮忙吗?我有一个多月的时间来处理这个问题:'( :'( :'(
When i change by my hand this offset it runs for different values of my database... How I can do it without change with my hand this offset?? Someone said me that I can do it without offset but he did not tell me how... Could someone help plz?? I have over a month with this issue :'( :'( :'(
推荐答案
$per_page = 10;
$current_page = read_current_page(); // 0,1,2...
$start = $current_page*$per_page;
$sql = 'SELECT * FROM t1
RIGHT OUTER JOIN t2 ON t2.wid = t1.wid
LIMIT ' . $start . ','. $per_page;
save_current_page(++$current_page);
应该是这样的.read_current_page() 应该以某种方式从文件、数据库或您决定保留该值的地方读取值.因此,您需要在调用之间存储它.
It should be something like that. read_current_page() should somehow read value from file, database or where ever you decide to keep that value. So, you need some place to store it between the calls.
然后您创建查询,最后您必须更新该计数器的值.添加一些逻辑来重置它,你需要的方式.但重点是您必须将其存储在代码之外的某个地方...因为在执行调用后所有值都将丢失.
Then you create your query and at end you have to update value of that counter. Add also some logic to reset it, the way you need it. But point is that you have to store it somewhere outside of your code...since after call is executed all values are lost.
这篇关于我希望这些行运行我数据库的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我希望这些行运行我数据库的所有值
基础教程推荐
- 无法解决整理冲突 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
