abc_list 
id    mid    title 
1      1    CSDN 
2      1    我是菜鸟 
abc_content 
rid  id  content 
1    1    CSDN论坛 
2    1    CSDN博客 
3    1    CSDN主页 
4    2    请高手帮忙 
5    2    谢谢! 
求一条SQL语句 跟具 `mid` `title` 进行查询 结果进行id排序 
比如:where `mid`=1 and `title` like "%CS%" ORDER BY id desc
想得到结果(`rid`取第一条)id   mid   title   rid   content
1     1    CSDN     1    CSDN论坛再求一条SQL语句 
上条SQL语句的 符合条件的记录总条数我的mysql 版本是MySQL 4.0.25-nt 

解决方案 »

  1.   

    上次的语句不对吗?select a.*,b.*
    from abc_list a left join abc_content b on a.id=b.id
    where not exists (select id from abc_content where id=a.id and rid<b.rid)
    and `mid`=1 and `title` like "%CS%" ORDER BY id desc
      

  2.   

    因为他的mysql是4.0.25,所以不支持子查询。
      

  3.   

    try:
    select * from abc_list a inner join abc_content b
    on a.id=b.id 
    where `mid`=1 and `title` like "%CS%"
    order by rid limit 1
      

  4.   

    不考虑排序
    可以这样子
    SELECT A.*,B.* FROM abc_list A LEFT JOIN abc_content B ON A.id=B.id WHERE A.mid='1' AND A.title LIKE '%CSDN%'  GROUP BY B.id但是又得排序。请高手帮忙。。谢谢了。
      

  5.   

    和上次一样,你先贴
    select * from abc_list ;
    select * from abc_content ;然后给出你期望的正确结果。否则只是文字描述很难正确的捕捉你的需求。