-1
SELECT 
    a.studentcode, 
    a.studentname, 
    a.fathername, 
    a.date, 
    c.centrename, 
    cm.feename, 
    l.location, 
    a.periodofissue, 
    a.image 
FROM admission a 
INNER JOIN centre c ON a.centreid = c.id 
INNER JOIN coursemaster cm ON a.courseid = cm.id 
INNER JOIN location l ON a.locationid = l.id where a.id in (".$pc.")

并在执行查询后发生错误,即:

“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以)在第 1 行的 ' '附近使用正确的语法SELECT a.studentcode, a.studentname, a.fathername, a.date, c.centrename, cm.feename, l.location, a.periodofissue, a.image FROM admission a INNER JOIN centre c ON a.centreid = c.id INNER JOIN coursemaster cm ON a.courseid = cm.id INNER JOIN location l ON a.locationid = l.id where a.id in ()

请给我解决方案

4

1 回答 1

0

也许尝试类似:

SELECT a.`studentcode` , a.`studentname` , a.fathername, a.date, 
       c.`centrename` , cm.`feename` , l.`location`, 
       a.periodofissue, a.image 
FROM admission a 
INNER JOIN centre c ON a.centreid = c.id 
INNER JOIN coursemaster cm ON a.courseid = cm.id 
INNER JOIN location l ON a.locationid = l.id 
where a.id in (select id from admission where id = ".$pc.")

或者:

SELECT a.`studentcode` , a.`studentname` , a.fathername, a.date, 
       c.`centrename` , cm.`feename` , l.`location`, 
       a.periodofissue, a.image 
FROM admission a 
INNER JOIN centre c ON a.centreid = c.id 
INNER JOIN coursemaster cm ON a.courseid = cm.id 
INNER JOIN location l ON a.locationid = l.id 
where a.id = ".$pc."
于 2013-02-05T07:01:04.790 回答