询问两张桌子

编程入门 行业动态 更新时间:2024-10-22 21:37:07
本文介绍了询问两张桌子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好,我需要查询哪个连接两个表。我该怎么做?我有这些表

手机品牌 PhoneID PhoneID PhoneName BrandName

如何将我的PhoneId插入品牌表

解决方案

在内部联接的帮助下,您可以这样做很简单,例如查询

选择 p.Phone,p.PhoneName,b.Brand,b.BrnadName from 电话p(第一个表名)内部加入品牌(第二名表)b on p.PhoneID = b.PhoneID

更多链接显示在下方信息如何使用Inner Join。 试试这个链接 www.tutorialspoint/sql/sql-inner-joins.htm [ ^ ]

先生,我想你应该反之亦然,如将 BranchId 字段添加到电话表,这将使其更合适,因为在分支机构中可以有50部电话但在一部电话中可以只有一个分支。

加入

选择 p.PhoneID,p.PhoneName,b.BrandName 来自电话p 内部 加入品牌b p.phoneid = b.brandid

insert

insert 进入品牌(phoneid,brandname)值(' phoneid',' 您的品牌名称)

Hi guys, I need to query which joins two tables. How should I do this? I have these tables

Phone Brand PhoneID PhoneID PhoneName BrandName

How do I get my PhoneId to be inserted in the Brand Table

解决方案

It's simple you can do this with the help of Inner Join, like this Query

select p.Phone,p.PhoneName,b.Brand,b.BrnadName from Phone p(first Table Name) inner join Brand(Second Table Name) b on p.PhoneID=b.PhoneID

More link are show below a complete information how can used the Inner Join. try this link www.tutorialspoint/sql/sql-inner-joins.htm[^]

sir, i think you should do it vice-versa like take BranchId field should be added to Phone table that will make it more appropriate because in a branch there can be 50 phones but in one phone there can be only 1 branch.

Joining

select p.PhoneID ,p.PhoneName ,b.BrandName from Phone p inner join brand b on p.phoneid = b.brandid

for insert

insert into brand ( phoneid , brandname) values ( 'phoneid','your brand name')

更多推荐

询问两张桌子

本文发布于:2023-10-28 18:16:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537397.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两张   桌子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!