【求救】数据库SQL语句问题
java吧
全部回复
仅看楼主
level 8
关联表 user_camera 字段uid,cid,camera_name
比如
id uid cid camera_name
1 1 1 1
2 1 2 2
udi是user表的主键ID cid是camera表的主键ID
camera表 字段:id,ieme,network,is_login
现在想通过一条sql语句 查询出 uid为1的用户所添加的摄像头的信息(camera_name,ieme,network,is_login) ...
这条语句该怎么写,不知道是数据库设计的表有问题还是怎么..完全木有思路。
求大神
2013年08月26日 06点08分 1
level 8
有无数据库方面的大神,无耻伸手了。[乖]
2013年08月26日 06点08分 2
select u.camera_name,c.ieme,c.network,c.is_login from camera c,user_camera u where u.uid=1 and u.uid=c.id
2013年08月26日 06点08分
是不是这个?我也不清楚你的数据关系是什么样子的
2013年08月26日 06点08分
回复 215804114 :我试了一下结果 返回的都是空,user_camera 表中关联了camera表的数据库id和user表的数据库id
2013年08月26日 06点08分
回复 215804114 :我把where u.uid=1 and u.uid=c.id 这里改成where u.uid=1 但是也不是我想要的结果
2013年08月26日 06点08分
level 8
2013年08月26日 06点08分 4
2013年08月26日 06点08分
level 5
就是按照你说的 第一个字段获取的就是用户所安装的设备名称 后面的字段我就不知道啥意图了
2013年08月26日 06点08分 5
好像是数据库设计的表有问题 ,我在自己钻研下,非常感谢你。
2013年08月26日 07点08分
level 12
提问很乱,清晰的表结构发来看看
2013年08月26日 07点08分 6
level 2
用user_camera做主表uc,左外连接camera表 c uc.on c_id=c.c_id 要查询某个用户where uc.u_id=XXX
2013年08月26日 08点08分 7
level 4
select c.cid,c.xxx,c.xx from user_camera u,camrea c where u.cid=c.cid and u.uid=1
2013年08月26日 09点08分 8
1