gpt4 book ai didi

mysql - 使用php获取多个表数据

转载 作者:行者123 更新时间:2023-11-29 04:14:15 25 4
gpt4 key购买 nike

假设我有两个表...我想按发布/添加日期或按 ID 排序获取两个表数据!

所以如果我有

table1
id msg date
2 this is msg nowdate

table2
id comment date
2 this is comment nowdate

那我怎样才能通过 id 在单个查询顺序中获取它呢?

最佳答案

UNION是这个词,你要找的是:

(SELECT * FROM table1) UNION (SELECT * FROM table2) ORDER BY id

关于mysql - 使用php获取多个表数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1832112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com