gpt4 book ai didi

php - 多个表和查询

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

我如何将这样的东西连接在一起:

$query = ("SELECT * FROM profiles,follow
WHERE follow.friend ='$user'
AND follow.user !='$user'
AND profiles.user1 =follow.user
ORDER BY id DESC limit 20");

("SELECT * FROM profiles WHERE user1='$user'");

我需要查询来显示两个不同的东西,我该怎么做。

最佳答案

这个?

SELECT
*
FROM
follows
INNER JOIN
profiles
ON (profiles.user1 = follow.user)
WHERE
follow.friend = '{$user}'
AND follow.user != '{$user}'
AND profiles.user1 = '{$user}'
ORDER BY
profiles.id DESC
LIMIT 20

关于php - 多个表和查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8325282/

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