今天建了一个模型,现在首页调用此模型的一些信息就写了一个模块
SQL:
select * from supe_hqitems a , supe_hqmessage b
where a.itemid=b.itemid and a.subject = (select subject from supe_hqitems where catid = 1 order by dateline desc limit 0,1) order by dateline desc
这个语句在PHPMYADMIN里测试是成功的!
放到模块里以后,首页调用时就出错了.
错误:
SupeSite info: MySQL Query Error
SQL: SELECT * from [Table]hqitems a , [Table]hqmessage b
where a.itemid=b.itemid and a.subject = (select subject from [Table]hqitems where catid = 1 order by dateline desc LIMIT 0,20
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
Errno.: 1064
竟然还有子查询,很浪费数据库资源的,将
select * from supe_hqitems a , supe_hqmessage b
where a.itemid=b.itemid and a.subject = (select subject from supe_hqitems where catid = 1 order by dateline desc limit 0,1) order by dateline desc
放到phpmyadmin中执行一次看能否运行成功。
将sql语句改成下面的试一下:
select * from supe_hqitems a , supe_hqmessage b
where a.itemid=b.itemid and a.subject = (select subject from supe_hqitems where catid = 1 order by dateline desc limit 0,1)
SQL: SELECT * from [Table]hqitems a , [Table]hqmessage b
where a.itemid=b.itemid and a.subject = (select subject from [Table]hqitems where catid = 1 order by dateline desc LIMIT 0,20
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
Errno.: 1064