--McIntyre Inner Join Pop Tarts use master; create table #PopTartsStore ( StoreId int primary key identity (1,1) , Flavor varchar (20) , Price dec(6,2) ) insert into #PopTartsStore values ('Apple Cinnamon', 9999.99) insert into #PopTartsStore values ('Brown Sugar', 9999.99) insert into #PopTartsStore values ('Strawberry', 9999.99) create table #PopTartsDistributor ( DID int primary key identity (1,1) , StoreId int , Distributors varchar(50) ) insert into #PopTartsDistributor values (1, 'Walgreens') insert into #PopTartsDistributor values (2, 'Walmart') insert into #PopTartsDistributor values (3, 'Wally''s') --st = #PopTartsStore --di = #PopTartsDistributor SELECT st.StoreId, st.Flavor, st.Price, di.Distributors From #PopTartsStore as st Inner Join #PopTartsDistributor as di on st.StoreId = di.StoreId select * from #PopTartsStore select * from #PopTartsDistributor
Monday, January 31, 2011
Advanced Relational Database /* Inner Join between two tables */
The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.Tables in a database are often related to each other with keys.A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table.
Subscribe to:
Post Comments (Atom)
Classes
Programming II
Advanced Relational Database
Blog Archive
-
▼
2011
(35)
-
▼
January
(19)
- Challenge me in Mini Putt!
- Advanced Relational Database /* Inner Join between...
- Programming 2 /* Case Statements */
- Programming 2 /* If Statements */
- How to draw a Cartoon Banana.
- Programming 2 /* Practice #1 - Acts and Facts */
- Programming 2 /* how to join a string to another s...
- Programming 2 /* how to convert an integer into a ...
- Advanced Relational Database /* Assignment 1 Frog ...
- Creating A Database in Microsoft SQL Server 1/24/11
- Converting a number variable into a string 1/24/11
- Variables in Visual Basic 1/24/11
- Advanced Relational Database /* Testing the creati...
- Advanced Relational Database /* Testing the creati...
- Advanced Relational Database /* Testing the creati...
- Advanced Relational Database /* Temp Tables and Ta...
- Programming 2 /* Repeatable Processing */ 1/19/11
- M&M
- Code
-
▼
January
(19)
No comments:
Post a Comment