我有2个表:glgroup和glref
mongoose.model( 'Foo', FooSchema )
我有这个问题:
CREATE TABLE `glgroup` (
`GLREFID` varchar(2) NOT NULL default '',
`GLREFNO` varchar(20) NOT NULL default '',
PRIMARY KEY (`GLREFID`,`GLREFNO`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE `glref` (
`GLREFNO` varchar(20) NOT NULL default '',
`GLDESC` varchar(255) NOT NULL default '',
`GLCUR` varchar(20) NOT NULL default '',
`GLADDFIELD` varchar(20) default NULL,
`GLADDFIELD2` varchar(20) default NULL,
`GLADDFIELD3` varchar(20) default NULL,
`GLADDFIELDDESC` tinytext,
PRIMARY KEY (`GLREFNO`,`GLCUR`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
有时(经常),此查询不返回任何行。如果我删除SELECT DISTINCT
GLREF.GLREFNO,
GLREF.GLDESC
FROM GLGROUP,
GLREF
WHERE GLGROUP.GLREFID = '07'
AND GLGROUP.GLREFNO = GLREF.GLREFNO
ORDER BY GLREF.GLREFNO;
子句,则返回76行(当它正确运行时,它也返回76行),如果我删除order by
和distinct
子句,则返回697行。
问题是,这个查询是在应用程序代码中,我无法修改它。我该怎么办?