gpt4 book ai didi

mysql - 这个 phpBB 的 SQL 有什么问题?

转载 作者:行者123 更新时间:2023-11-30 23:12:41 25 4
gpt4 key购买 nike

更新的 SQL:环境是 MySQL 5.5。 SQL 是通过 phpBB 抽象层生成的,但是当我看到 SQL 时,它看起来是有效的。

SELECT f.*, t.*, p.*, u.*, tt.mark_time AS topic_mark_time, ft.mark_time AS forum_mark_time
FROM (phpbb_posts p CROSS JOIN phpbb_users u CROSS JOIN phpbb_topics t) LEFT JOIN
phpbb_forums f ON (t.forum_id = f.forum_id) LEFT JOIN phpbb_topics_track tt ON
(t.topic_id = tt.topic_id AND tt.user_id = 2) LEFT JOIN phpbb_forums_track ft ON
(f.forum_id = ft.forum_id AND ft.user_id = 2) WHERE p.topic_id = t.topic_id AND
p.poster_id = u.user_id AND p.post_time > 1380495918 AND p.forum_id IN (7, 6, 5, 3, 4, 2, 1)
AND p.post_approved = 1 ORDER BY t.topic_last_post_time DESC, p.post_time LIMIT
18446744073709551615

错误是:

“on 子句”[1054] 中的未知列“t.topic_id”

所有列名都存在。所有表都存在。所有别名都存在。

相关代码如下:

$sql_array = array(
'SELECT' => 'f.*, t.*, p.*, u.*, tt.mark_time AS topic_mark_time, ft.mark_time AS forum_mark_time',

'FROM' => array(
POSTS_TABLE => 'p',
USERS_TABLE => 'u',
TOPICS_TABLE => 't'),

'WHERE' => "$topics_posts_join_sql
AND p.poster_id = u.user_id
$date_limit_sql
$fetched_forums_str
$new_topics_sql
$remove_mine_sql
$filter_foes_sql
AND p.post_approved = 1",

'ORDER_BY' => $order_by_sql
);

$sql_array['LEFT_JOIN'] = array(
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 't.forum_id = f.forum_id'
),
array(
'FROM' => array(TOPICS_TRACK_TABLE => 'tt', FORUMS_TRACK_TABLE => 'ft'),
'ON' => "t.topic_id = tt.topic_id AND tt.user_id = $user_id"
),
array(
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
'ON' => "f.forum_id = ft.forum_id AND ft.user_id = $user_id"
)
);

$sql = $db->sql_build_query('SELECT', $sql_array);

最佳答案

t.topic_id = TOPICS_TRACK_TABLE.topic_i

错了。确保它使用正确的别名 tt

关于mysql - 这个 phpBB 的 SQL 有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19214488/

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