万网租的空间,数据库是mysql4.0。
查询语句如下:
SELECT 
 NoticeID,
 (select UserName from Zcml_User where UserID=Zcml_Notice.NoticeAud)NoticeAud 
 from Zcml_Notice 
where NoticeType='0' 
order by NoticeStatus,NoticeAddDate DESC
提示错误:
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 'select UserName from Zcml_User where UserID=Zcml_Notice.NoticeA 
请高手帮忙解决。谢谢!

解决方案 »

  1.   

    mysql 4不支持子查询SELECT 
     NoticeID,
     (select UserName from Zcml_User where UserID=Zcml_Notice.NoticeAud)NoticeAud 
     from Zcml_Notice 
    where NoticeType='0' 
    order by NoticeStatus,NoticeAddDate DESC
      

  2.   

    select a.NoticeID,b.UserName
    from Zcml_Notice a ,Zcml_User b
    where a.NoticeAud=b.UserID
    and a.NoticeType='0'
    order by a.NoticeStatus,a.NoticeAddDate DESC
      

  3.   

    建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。   
      

  4.   

    select a.NoticeID,b.UserName
    from Zcml_Notice a left join Zcml_User b on a.NoticeAud=b.UserID
    where a.NoticeType='0'
    order by a.NoticeStatus,a.NoticeAddDate DESC
      

  5.   

    表Zcml_User
    UserID   UserName
    admin    管理员
    aa       用户1
    bb       用户2
    cc       用户3表Zcml_Notice
    NoticeID    NoticeTitle  NoticeAud
    01          标题1         aa
    02          标题2         aa
    03          标题3         cc
    04          标题4         bb想要如下的查询结果:
    01 标题1 用户1
      

  6.   

    select a.NoticeID,a.NoticeTitle,b.UserName
    from Zcml_Notice a,Zcml_User b
    where a.NoticeAud=b.UserID
      

  7.   

    当表Zcml_Notice的NoticeAud字段为空时如何使该条记录仍旧显示出来?
    谢谢!! 
      

  8.   


    select a.NoticeID,a.NoticeTitle,b.UserName
    from Zcml_Notice a,Zcml_User b
    where a.NoticeAud=b.UserID or a.NoticeAud is null;
      

  9.   

      #5楼 已经给过你答案了。select a.NoticeID,a.NoticeTitle,b.UserName
    from Zcml_Notice a left join Zcml_User b on a.NoticeAud=b.UserID
      

  10.   

    我也是万网租的服务器,数据库实在差,MySQL4既不支持子查询,也不支持存储过程,NND