SQL查询中出现问题 [英] Problem occured in sql query

查看:67
本文介绍了SQL查询中出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2张桌子


I have a 2 tables

Domain

DCode        DName                   Cuscode
D001        www.sample.com          US0001
D002        Www.sample1.com         US0001
D003        www.sample3.com         US0002



虚拟主机



Webhost

Wcode      Wname              Cuscode
W001       webhost1           US0001
W002       webhost2           US0001
W003       webhost3           US0002



我想从两个以上的表中获取相同的cuscode的值



I want to get the values from above two tables like this for same cuscode

Code     Name
D001      Www.sample.com
D002      WWW.sample1.com
W001      webhost1
W002      webhost2



如何做到这一点,任何人都可以帮助解决这个问题

在此先感谢



How to do it please anyone can help this problem

Thanks in advance

推荐答案

UNION [ ^ ]可能会帮助您

使用以下查询,这可能对您有帮助

UNION[^] may helps you

use the below query, this may helps you

select code,name from(
select decode as code,dname as name from table1
union
select wcode as code,wname as name from table2)


这篇关于SQL查询中出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆