Click here to Skip to main content
15,887,886 members
Home / Discussions / Database
   

Database

 
GeneralRe: .NET Pin
Paul Conrad3-Apr-07 18:04
professionalPaul Conrad3-Apr-07 18:04 
QuestionQuery Pin
Devkranth Kishore Vanja2-Apr-07 21:05
Devkranth Kishore Vanja2-Apr-07 21:05 
AnswerRe: Query Pin
jijoaresseriljose2-Apr-07 21:44
jijoaresseriljose2-Apr-07 21:44 
GeneralRe: Query Pin
Devkranth Kishore Vanja2-Apr-07 22:14
Devkranth Kishore Vanja2-Apr-07 22:14 
AnswerRe: Query Pin
Krish - KP2-Apr-07 22:03
Krish - KP2-Apr-07 22:03 
QuestionAdding a foreign key SQL Compact edition Pin
daabs2-Apr-07 19:12
daabs2-Apr-07 19:12 
AnswerRe: Adding a foreign key SQL Compact edition Pin
daabs2-Apr-07 23:34
daabs2-Apr-07 23:34 
Questionselect data from two tables ...??? Pin
vicky4572-Apr-07 9:44
vicky4572-Apr-07 9:44 
Hi,
I have two tables as following:

Table1:
AccountID Symbol Fee Price
1 AAA 10 150
1 AAA 20 250
1 BBB 30 350
2 AAA 40 450
2 CCC 50 550
3 DDD 60 650
4 EEE 70 750
6 HHH 15 250

Table2:
AccountID Symbol Share Dollar
1 AAA 100 1100
1 BBB 200 2200
2 AAA 300 3300
2 AAA 400 4400
2 CCC 500 5500
3 DDD 600 6600
4 FFF 700 7700
5 GGG 800 8800

These two tables have two common fields: AccountId and Symbol. What I want to do is to get all the data from both tables based on the same accountid and the same symbol. If one table (A) doesn't contain the account or symbol in the other table (B), just fill the column in table (A) with blanks. The result should look like:

AccountID Symbol Fee Price Share Dollar
1 AAA 10 150 100 1100
1 AAA 20 250 --- ---
1 BBB 30 350 200 2200
2 AAA 40 450 300 3300
2 AAA -- --- 400 4400
2 CCC 50 550 500 5500
3 DDD 60 650 600 6600
4 EEE 70 750 --- ----
4 FFF -- --- 700 7700
5 GGG -- --- 800 8800
6 HHH 15 250 --- ----

The columns Fee and Price in Table1 don't have relationship with the columns Share and Dollar in Table2. All I need is to display data from both table based on Account and Symbol. And I need to do it using T-SQL.

Any hint and suggestion would be appreciated.

Thanks in advance!
AnswerRe: select data from two tables ...??? Pin
Krish - KP2-Apr-07 17:40
Krish - KP2-Apr-07 17:40 
GeneralRe: select data from two tables ...??? Pin
vicky4573-Apr-07 5:02
vicky4573-Apr-07 5:02 
AnswerRe: select data from two tables ...??? Pin
jijoaresseriljose2-Apr-07 20:59
jijoaresseriljose2-Apr-07 20:59 
GeneralRe: select data from two tables ...??? Pin
vicky4573-Apr-07 4:57
vicky4573-Apr-07 4:57 
QuestionSQL 2005 Express Question Pin
Ian Perera2-Apr-07 8:31
Ian Perera2-Apr-07 8:31 
AnswerRe: SQL 2005 Express Question Pin
Brent Lamborn3-Apr-07 5:35
Brent Lamborn3-Apr-07 5:35 
QuestionDataGridView vb.net 2005 Pin
kindman_nb2-Apr-07 7:59
kindman_nb2-Apr-07 7:59 
Questionerror while creating the table Pin
pratima12-Apr-07 3:19
pratima12-Apr-07 3:19 
AnswerRe: error while creating the table Pin
gauthee2-Apr-07 3:23
gauthee2-Apr-07 3:23 
GeneralRe: error while creating the table Pin
pratima12-Apr-07 3:34
pratima12-Apr-07 3:34 
GeneralRe: error while creating the table Pin
gauthee2-Apr-07 3:47
gauthee2-Apr-07 3:47 
AnswerRe: error while creating the table Pin
Vimalsoft(Pty) Ltd11-Apr-07 0:58
professionalVimalsoft(Pty) Ltd11-Apr-07 0:58 
QuestionDeletion with relationship Pin
sujithkumarsl2-Apr-07 2:45
sujithkumarsl2-Apr-07 2:45 
AnswerRe: Deletion with relationship Pin
joon vh.2-Apr-07 3:15
joon vh.2-Apr-07 3:15 
QuestionHi Pin
sree reddy1-Apr-07 23:24
sree reddy1-Apr-07 23:24 
AnswerRe: Hi Pin
sree reddy1-Apr-07 23:26
sree reddy1-Apr-07 23:26 
AnswerRe: Hi Pin
Colin Angus Mackay2-Apr-07 0:08
Colin Angus Mackay2-Apr-07 0:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.