2012-01-14 86 views
-5
$rs=mysql_query("select user.userName,usertype.userType from user,usertype where user.userTypeId=usertype.userTypeId"); 

此查询获取用户的类型,有2个类型(用户和管理员)。所以我只需要看到简单的用户而不是管理员。如何解决它?号码1是管理员类型,号码2是简单的用户。从数据库中选择用户

+1

试图得到一个SQL查询MySQL控制台(或phpMyAdmin的)上工作第一。 – greut 2012-01-14 16:45:55

回答

1

没有看到您的模式,这几乎是不可能回答,但你可能希望做这样的事情:

select user.userName, usertype.userType 
    from user, usertype 
    where user.userTypeId = usertype.userTypeId 
    and usertype.role = 'user' 
+0

非常感谢你,我解决它。 – Simon 2012-01-14 16:48:10

+1

@Simon你应该接受这个答案,检查旁边的勾号。 – 2012-01-14 16:51:10