早教吧作业答案频道 -->其他-->
sql两个表连接查询,如何将列变成一行显示有两个表,customer和phone,customer主键是customerid,phone主键是phoneid其结构如下customercustomerid,customername,address1alll2bdddpho
题目详情
sql两个表连接查询,如何将列变成一行显示 有两个表,customer和phone,customer主键是customerid,phone主键是phoneid其结构如下
customer
customerid,customername,address
1 a lll
2 b ddd
phone
phoneid,customerid,phonenum
1 1 123
2 1 234
3 1 342
4 2 366
5 2 333
如何实现这样的查询结果
customerid,customername,address,phonenum1,phonenum2,phonenum3
1 a lll 123 234 342
customer
customerid,customername,address
1 a lll
2 b ddd
phone
phoneid,customerid,phonenum
1 1 123
2 1 234
3 1 342
4 2 366
5 2 333
如何实现这样的查询结果
customerid,customername,address,phonenum1,phonenum2,phonenum3
1 a lll 123 234 342
▼优质解答
答案和解析
select customer.customerid,customername,address,phoneid,phonenum1,phonenum2,phonenum3 from customer,phone where customer.customerid=phone.customerid and customer.customerid = 1;
注意:可能有字段名拼写错误,使用前请检查
看了 sql两个表连接查询,如何将...的网友还看了以下:
设A为n阶矩阵,证明:R(A+I)+R(A-I)>=n已知R(A)=R(kA),k≠0;R(A+B 2020-05-14 …
已知字母组合成英语单词1、e e t t i n h r 2、e e r a t w h 3、o 2020-05-14 …
for(m=0,i=k;i>=0;i--,m )0);case"l":case"L":system 2020-05-14 …
将字母组成单词,并译成汉语1.m,e,r,m,u,s,汉语2.u,l,t,e,c,u,r,汉语3. 2020-06-04 …
用以下英文宇母填在上a,a,a,a,a,a,b,e,e,d,e,e,e,e,e,e,f,g,g用以 2020-06-24 …
设一组初始记录关键字序列为(Q,H,C,Y,P,A,M,S,R,D,F,X),则按字母升序的第一趟 2020-07-17 …
设全集I={复数},R={实数},M={纯虚数},则()A.M∪R=IB.∪R=IC.∩R=R 2020-07-30 …
(Rob=RMom=M)R:Hi,Mom.I'mbacknow!M:Wherehaveyou(81) 2020-10-31 …
根据上下文的语境,用适当的单词完成句子,每空一词。(Rob=RMom=M)R:HiMom.I'mba 2020-10-31 …
急中级财务管理实际利率和名义利率之间关系式中m是什么i=(1+r/m)m-1中的三个问题一、i是实际 2020-11-21 …