【发布时间】:2012-06-12 22:43:22
【问题描述】:
我的一台服务器上的某个查询出现问题。在我测试过的所有其他地方它工作得很好,但在我想使用它的服务器上它不工作。
关于下面的SQL:
SELECT facturen.id AS fid,
projecten.id AS pid,
titel,
facturen.totaal_bedrag AS totaal,
betaald,
datum
FROM facturen,
projecten
WHERE facturen.project_id = projecten.id
AND projecten.eigenaar = '1'
ORDER BY datum DESC
这是我从中得到的错误代码:
SELECT command denied to user 'marco'@'localhost' for table 'projecten'
表格: 制造商:
CREATE TABLE IF NOT EXISTS `facturen` (
`id` int(11) NOT NULL auto_increment,
`project_id` int(11) NOT NULL,
`datum` int(11) NOT NULL,
`lever_datum` int(11) NOT NULL,
`totaal_bedrag` decimal(9,2) NOT NULL,
`btw` decimal(9,2) NOT NULL,
`bedrijf` varchar(40) NOT NULL,
`contactpersoon` varchar(60) NOT NULL,
`adres` varchar(60) NOT NULL,
`postcode` varchar(7) NOT NULL,
`plaats` varchar(30) NOT NULL,
`betaald` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200006 ;
投影:
CREATE TABLE IF NOT EXISTS `projecten` (
`id` int(11) NOT NULL auto_increment,
`titel` varchar(80) NOT NULL,
`eigenaar` int(11) NOT NULL,
`creatie_datum` int(11) NOT NULL,
`eind_datum` int(11) NOT NULL,
`totaal_bedrag` decimal(9,2) NOT NULL,
`btw` decimal(9,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=201200004 ;
奇怪的是,'projecten' 表和 'facturen' 表上的所有其他查询都可以正常工作,这个查询在我的另外两台服务器上也可以正常工作。
【问题讨论】:
-
bt2.projecten 中的 bt2 是什么?
-
我的一个错字,因为我把它从我的旧数据库复制到这里。它不在主数据库上,所以问题没有得到解决。这也不是特权问题,因为我获得了完全访问权限。
-
你能打印出你的权限表的结果吗?
-
@matthewdavidson,授予所有特权;)
-
没关系,但是您是否尝试过为没有名称冲突的字段使用限定名称?那么
projecten.titel之类的?