选择列insql服务器上的问题 [英] problem on selecting column insql server
本文介绍了选择列insql服务器上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI
我正在开发数据库应用程序.
我有一个表名存储ID,名称,信息,地址,...的人.还有另一个存储2个ID的表名组,这两个ID都指向表People的ID.
我想从组表中选择,但要选择ID而不是ID,我该怎么做.对不起,我的英语不好.
HI
I am working on a database application.
I have a Table name people that store ID , name , info , address ,... ; And another table name group that store 2 id that both of them point to id of table People .
I want to select from group table but instead of id , their name would be selected , How can I do that . sorry for my bad english .
推荐答案
您的问题不清楚.据我了解,您想基于id或
从两个表中进行选择 我错过了什么吗?
Your question is not clear. As I understand you want to select from both tables based on id or
did I miss anything.
Select c.id, c.Name, c.Address, ct.groupname, ct.ID FROM people AS c Inner Join [group] as ct on ct.ID=c.id
sql joins[^]
这是您想要的吗?
Is this what you want?
SELECT u.[name]
FROM [users] u
JOIN [groupUser] gr1
OM gr1.[userID1] = u.[userId]
JOIN [groupUser] gr2
OM gr1.[userID2] = u.[userId]
我认为您应该重新考虑表[groupUser]的设计,如果以后在一个组中需要3个或更多用户怎么办?
I think you should reconsider the design of the table [groupUser], what if later you need 3 or more users in a group?
这篇关于选择列insql服务器上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文