我有 3 张 table 。我想按日期从中选择数据。我将日期保存在所有表中的 unixtimestamp 中。我正在使用以下查询:
select
c.up_date, c.user_id, c.id,
f.id, f.up_date, f.friend1, f.friend2, f.status,
s.postdate, s.status, s.id, s.display_name, s.userid, s.userid1
from
c.cover_pic,
s.wp_userstatus,
f.wp_friends
where
s.userid=c.friend1
and s.userid=c.user_id
and f.status=1
and c.user_id=4
order by s.postdate
表格结构为:cover_pic 表格:
id user_id coverpic color up_date
1 4 496b02165600889daf51c6b04b257ec0.jpg 63ACFF 1353069741
wp_friends 表:
id friend1 friend2 status up_date
12 1 4 2 1353064093
11 4 1 1 1353064093
wp_userstatus 表:
id status display_name userid userid1 postdate
6 awesome paramveer 4 4 1352414658
7 lets paramveer 4 4 1352414932
它显示以下错误:
#1142 - SELECT command denied to user 'kdgadget'@'localhost' for table 'cover_pic'
我想按日期顺序显示数据。
最佳答案
SELECT command denied to user 'kdgadget'@'localhost' for table 'cover_pic'
应该是一个明确的信息。用户 kdgadget 不能对表 cover_pic 执行 SELECT 命令。所以这是数据库配置问题,而不是查询问题。
关于mysql - sql查询从多个表中选择数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13417382/