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 

解决方案 »

  1.   

    第二个问题.
    $query4="select count(id)<--注意这儿用ID,不要滥用* --> as total from read";
    $result4=mysql_query($query4);
    $totalnum=mysql_fetch_array($result4);//总记录数为$totalnum
    echo $totalnum['total'];
      

  2.   

    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
      

  3.   

    错误
    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怎么办?就要面试了,但是还是这么多的错误
    作品还是没有完成~~~~
    怎么办啊?
      

  4.   

    错误
    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 ………………出鬼了~~~
      

  5.   


    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 
      

  6.   

    实在不行,你就别read.*了,直接写read.具体字段名
      

  7.   

    read是保留关键字.加界定符就行了.我刚刚都忽略了这一点.
    注意养成好的习惯.表和字段都加上界定符.
      

  8.   

    学习
    问下
    select * from a,b,c where a.id=b.id and b.id=c.id  这样行不?
      

  9.   


    这个不行的。
    因为文章read的cid 可以为空。