SELECT read.*,user.uname,category.cname FROM read LEFT JOIN user ON(read.uid=user.uid) LEFT JOIN category ON(read.cid=category.cid) ORDER BY read.date DESC LIMIT 0,10
第二个问题. $query4="select count(id)<--注意这儿用ID,不要滥用* --> as total from read"; $result4=mysql_query($query4); $totalnum=mysql_fetch_array($result4);//总记录数为$totalnum echo $totalnum['total'];
SELECT a.*, b.uname, c.cname FROM read a left join user b ON a.uid=b.uid left join category c ON a.cid=c.cid
错误 SQL 查询: SELECT READ . * , category.cname, user.uname FROM READ LEFT JOIN category ON ( read.cid = category.cid ) LEFT JOIN user ON ( read.uid = user.uid ) ORDER BY read.rdate DESC LIMIT 0 , 5 MySQL 返回: #1064 - 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 'read.*,category.cname,user.uname from read left join category on (read.cid=categ' at line 1怎么办?就要面试了,但是还是这么多的错误 作品还是没有完成~~~~ 怎么办啊?
错误 SQL 查询: SELECT READ . * , user.uname, category.cname FROM READ LEFT JOIN user ON ( read.uid = user.uid ) LEFT JOIN category ON ( read.cid = category.cid ) ORDER BY read.date DESC LIMIT 0 , 10 MySQL 返回: #1064 - 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 'read.*,user.uname,category.cname FROM read LEFT JOIN user ON(read.uid=user' at line 1 ………………出鬼了~~~
SELECT `read`.*,`user`.`uname`,`category`.`cname` FROM `read` LEFT JOIN `user` ON(`read`.`uid`=`user`.`uid`) LEFT JOIN `category` ON(`read`.`cid`=`category`.`cid`) LIMIT 0,10
$query4="select count(id)<--注意这儿用ID,不要滥用* --> as total from read";
$result4=mysql_query($query4);
$totalnum=mysql_fetch_array($result4);//总记录数为$totalnum
echo $totalnum['total'];
FROM read a
left join user b ON a.uid=b.uid
left join category c ON a.cid=c.cid
SQL 查询: SELECT READ . * , category.cname, user.uname
FROM READ LEFT JOIN category ON ( read.cid = category.cid )
LEFT JOIN user ON ( read.uid = user.uid )
ORDER BY read.rdate DESC
LIMIT 0 , 5 MySQL 返回: #1064 - 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 'read.*,category.cname,user.uname from read left join category on (read.cid=categ' at line 1怎么办?就要面试了,但是还是这么多的错误
作品还是没有完成~~~~
怎么办啊?
SQL 查询: SELECT READ . * , user.uname, category.cname
FROM READ LEFT JOIN user ON ( read.uid = user.uid )
LEFT JOIN category ON ( read.cid = category.cid )
ORDER BY read.date DESC
LIMIT 0 , 10 MySQL 返回: #1064 - 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 'read.*,user.uname,category.cname
FROM read LEFT JOIN user ON(read.uid=user' at line 1 ………………出鬼了~~~
SELECT `read`.*,`user`.`uname`,`category`.`cname`
FROM `read`
LEFT JOIN `user` ON(`read`.`uid`=`user`.`uid`)
LEFT JOIN `category` ON(`read`.`cid`=`category`.`cid`)
LIMIT 0,10
注意养成好的习惯.表和字段都加上界定符.
问下
select * from a,b,c where a.id=b.id and b.id=c.id 这样行不?
这个不行的。
因为文章read的cid 可以为空。