Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 6-Feb-14 5:09am
v2

It's simple you can do this with the help of Inner Join, like this Query
C#
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
http://www.tutorialspoint.com/sql/sql-inner-joins.htm[^]
 
Share this answer
 
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.
 
Share this answer
 
Joining
SQL
select p.PhoneID ,p.PhoneName ,b.BrandName from Phone p inner join brand b on p.phoneid = b.brandid


for insert
SQL
insert into brand ( phoneid , brandname) values ( 'phoneid','your brand name')
 
Share this answer
 
SELECT p.Phone, p.PhoneName , b.Brand, b.BrandName From table1 INNERJOINS table2 WHERE p.Phoneid = b. Phoneid
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900