mysql - sql查询从多个表中选择数据

标签 mysql sql

我有 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/

相关文章:

php - 从 PHP 脚本运行 mysqldump 不起作用,但可以在 SSH 上运行

php 无法通过查询创建新的数据库表

mysql - 希望通过 MYSQL 提取字符串中括号之间的数据

php - mySQL:我需要在 int 列中输入小数

php - 从表中获取多个值

C# 无效的对象名称 ASP.NET

mysql - 无法将列添加到表中 - mysql

MySQL:如何总结行的值并对结果进行排序?

mysql - 从两个表 MySql 中选择行

mysql - 插入时为什么闭包表指向自身