将预先连接的表连接到一张表中
我有两个连接表,我之前已与其他表连接,我希望“ddid”与“confid1”链接,
这是代码:
SELECT r.domainid, r.dombegin, r.domend, d.ddid
FROM domainregion AS r
JOIN dyndomrun AS d ON r.domainid::varchar(8) = d.ddid
ORDER BY r.domainid, d.ddid, r.dombegin, r.domend;
最后
(SELECT confid1 as id1, conformer.pdbcode, conformer.chainid
from dyndomrun JOIN conformer
ON dyndomrun.confid1 = conformer.id)
UNION
(SELECT confid2 as id2, conformer.pdbcode, conformer.chainid
from dyndomrun JOIN conformer ON dyndomrun.confid2 = conformer.id)
,我想要一个包含domainid、dombegin的新表、domend、ddid、confid1、pdbcode、chainid。
这是否可以做到,因为当我尝试对预连接表进行并集时,它给我带来了一个错误,指出每个 UNION 查询必须具有相同数量的列。
请指教。谢谢。
I have two joined tables that i have joined up with other tables previously and i would like "ddid" to link up with "confid1"
Here is the code :
SELECT r.domainid, r.dombegin, r.domend, d.ddid
FROM domainregion AS r
JOIN dyndomrun AS d ON r.domainid::varchar(8) = d.ddid
ORDER BY r.domainid, d.ddid, r.dombegin, r.domend;
and
(SELECT confid1 as id1, conformer.pdbcode, conformer.chainid
from dyndomrun JOIN conformer
ON dyndomrun.confid1 = conformer.id)
UNION
(SELECT confid2 as id2, conformer.pdbcode, conformer.chainid
from dyndomrun JOIN conformer ON dyndomrun.confid2 = conformer.id)
At the end, I would like to have a new table containing domainid, dombegin, domend, ddid, confid1, pdbcode, chainid.
Is this possible to do because it threw me an error when i tried doing a union of a pre-joined table, stating that each UNION query must have the same number of columns.
Please advise. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话:
If I understand you correctly:
这样的事情行不通吗?
应该会很慢吧
Wouldn't something like this work?
Probably be slow.