-1
select 
    ag.name, aa.name, al.object_id, u.name, al.performed_by, al.datetime, 
    aa1.name, et.name, ald.name, ald.value
from 
    'db'.'table1' al, 'db'.'table2' ald, 'db'.'table3' ag, 
    'db'.'table4' aa, 'db'.'table5' aa1, 'db'.'table6' et, 
    'db'.'table7' u
where 
    al.id = ald.log_id 
    and al.datetime > DATE_SUB(sysdate(). INTERVAL 90 DAY) 
    and al.group_id = ag.id 
    and ag.name = 'User' 
    and al.action_id = aa1.id 
    and al.object_id = u.user_id 
    and ald.type_id = et.id;

上面的查询在 mysql 中返回空集,但数据存在。如何解决它?

请帮助...在此先感谢...

4

1 回答 1

0

不要在表数据库周围使用单引号,列名使用反引号。

尝试这个:

     from 
`db`.`table1` al, `db`.`table2` ald, `db`.`table3` ag, 
`db`.`table4` aa, `db`.`table5` aa1, `db`.`table6` et, 
`db`.`table7` u 

试试这个加入

    select 
ag.name, aa.name, al.object_id, u.name, al.performed_by, al.datetime, 
aa1.name, et.name, ald.name, ald.value
from 
`db`.`table1` al  
Inner join `db`.`table2` ald On al.id = ald.log_id 
Inner join  `db`.`table3` ag On  al.group_id = ag.id
Inner join  `db`.`table4` aa On  """""the condition of relation with this table""""
Inner join  `db`.`table5` aa1 On al.action_id = aa1.id
Inner join  `db`.`table6` et On  ald.type_id = et.id
Inner join `db`.`table7` u  On al.object_id = u.user_id 
where 
  al.datetime > DATE_SUB(sysdate(), INTERVAL 90 DAY) 
  and ag.name = 'User' 
于 2013-08-14T20:00:57.580 回答