PHP MySQL:如何选择多个表并以良好的性能返回输出摘要?
如何在 PHP 上获取结果:
- NU61 - sun - 2011
- KE2I - ball - 2000
- B8WO - point - 2008
table_first SELECT id, order, date FROM table_first ORDER BY订单 DESC
return id
, date
id | orders | date
------+---------+------
KE2I | 2 | 2000
B8WO | 5 | 2008
NU61 | 1 | 2011
table_second SELECT key FROM table_second WHERE id=(id from table_first)
get key
访问 table_third
中的 content
id | key
------+-----------------
KE2I | .b
B8WO | .p
NU61 | .s
table_third SELECT content FROM table_third WHERE id=(key from table_second)
返回内容
id | content
------+-----------------
.b | ball
.p | point
.s | sun
How to get result on PHP:
- NU61 - sun - 2011
- KE2I - ball - 2000
- B8WO - point - 2008
table_first SELECT id, order, date FROM table_first ORDER BY orders DESC
return id
, date
id | orders | date
------+---------+------
KE2I | 2 | 2000
B8WO | 5 | 2008
NU61 | 1 | 2011
table_second SELECT key FROM table_second WHERE id=(id from table_first)
get key
to reach content
from table_third
id | key
------+-----------------
KE2I | .b
B8WO | .p
NU61 | .s
table_third SELECT content FROM table_third WHERE id=(key from table_second)
return content
id | content
------+-----------------
.b | ball
.p | point
.s | sun
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要您有以下方面的索引,性能就不会成为问题:
Performance will not be a concern as long as you have indices on:
这个查询可以解决问题:
This query would do the trick: