zhuzhanjun 发表于 2008-7-4 11:27

【求助】查询语句,两个表联系的关系

表1  :  id   title    user
         1   测试1   用户1
         2   测试2   用户2
         3   测试3   用户3
         11  测试4   用户8


表2:   id   username  user_type
         1    用户1      1
         2    用户2      3
         3    用户3      1
         4    用户8      2


然后我显示的数据是表1的,但是用户类型是1的数据不显示出来。怎么实现呢

效果如下:
         2   测试2   用户2
         11  测试4   用户8


在线等。谢谢

madpbpl 发表于 2008-7-4 11:50

select title,username from 表1,表2 where 表1.user=表2.username and 表2.user_type=1

zhuzhanjun 发表于 2008-7-4 12:00

谢谢楼上的兄弟,不行啊。你的语句查出的是类型等于1的数据,我要的是类型不等于1的数据。

select * from content a, t_user b where a.user=b.username and  b.login_type<>'1'
然后是空值啊

[[it] 本帖最后由 zhuzhanjun 于 2008-7-4 12:04 编辑 [/it]]

madpbpl 发表于 2008-7-4 12:10

不好意思,看错了。这样呢
select a.title,a.user from content a, t_user b where a.user=b.username and  b.login_type<>1

zhuzhanjun 发表于 2008-7-4 12:21

谢谢楼上的兄弟~~

页: [1]

编程论坛