gpt4 book ai didi

mysql - 选择查询连接两个表?

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:25 24 4
gpt4 key购买 nike

<分区>

tableone: id | userid | date | photo | caption | visible
tabletwo: id | userid | date | text | gender | notes

我有两个包含不同列的表。我想使用单个查询从两者中选择行,我会使用日期(时间戳)和用户 ID 来执行此操作。是否可以将它们连接在一起?

SELECT id, photo, caption, visible
FROM `tableone`
WHERE `userid` = $user->id AND `date` = '$d'
ORDER BY date desc

SELECT id, text, gender, notes
FROM `tabletwo`
WHERE `userid` = $user->id AND `date` = '$d'
ORDER BY date desc
LIMIT 1

编辑:期望的输出:

(
[id] => 3
[photo] => 1
[caption] => Sample text
[visible] => 1
[text] =>
[gender] =>
[notes] =>
)
(
[id] => 23
[photo] => 1
[caption] => More sample text
[visible] =>
[text] =>
[gender] =>
[notes] =>
)
(
[id] => 1
[photo] =>
[caption] =>
[visible] =>
[text] => Blah jaspidj
[gender] => 2
[notes] => Sample Text
)

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