Click here to Skip to main content
15,888,019 members
Home / Discussions / Database
   

Database

 
Questionpls help me out..its urgent... Pin
rs_net2-Jan-06 22:14
rs_net2-Jan-06 22:14 
GeneralSQL Server upgrade Problem Pin
dl4gbe2-Jan-06 16:02
dl4gbe2-Jan-06 16:02 
GeneralRe: SQL Server upgrade Problem Pin
JimmyRopes2-Jan-06 17:16
professionalJimmyRopes2-Jan-06 17:16 
GeneralRe: SQL Server upgrade Problem Pin
dl4gbe2-Jan-06 17:52
dl4gbe2-Jan-06 17:52 
GeneralRe: SQL Server upgrade Problem Pin
JimmyRopes3-Jan-06 5:43
professionalJimmyRopes3-Jan-06 5:43 
GeneralRe: SQL Server upgrade Problem Pin
dl4gbe3-Jan-06 21:00
dl4gbe3-Jan-06 21:00 
GeneralRe: SQL Server upgrade Problem Pin
JimmyRopes3-Jan-06 23:34
professionalJimmyRopes3-Jan-06 23:34 
QuestionSQL command optimization Pin
Wjousts2-Jan-06 10:06
Wjousts2-Jan-06 10:06 
Here's my problem. I'm using Oracle 8i and I do not have the option of changing the design of the database. I have a master table with some fields and a unique key Code, something like this:

Code     Field1     Field2
11111    1          2
11112    2          3
...


I also have another child table that contains some data that is related to my master table. It has two fields Key1 and Key2 which combined are unique:

Key1     Key2    Data1
1        1       1
1        2       5
2        1       12
2        2       3
...


Now, Key1 is linked to the master table through another "link" table:
Code     Key1
11111    1
11112    2
...


Now what I want to end up with is this:
Code     Field1    Field2    Key2_1data     Key2_2data   ...
11111    1         2         1              5
11112    2         3         12             3

In other words, the original table with fields added with the value of Data1 from the child table for each value of Key2. I hope that made sense. So I tried something like this:

SELECT master.code, master.Field1, master.Field2, (SELECT child.Data1 FROM child WHERE child.Key1 = link.Key1 AND child.Key2 = 1) AS Key2_1data, (SELECT child.Data1 FROM child WHERE child.Key1 = link.Key1 AND child.Key2 = 2) AS Key2_2data FROM master, link WHERE master.Code = link.Code (+)

This works and can be expanded for an arbitary number of values of Key2 by adding more of these nested select statements and there are actually only 10 values of Key2 for me to worry about, but that could change at some point. It just seems like it is a hugely ineffecient way to do things through. Is there a better way?
AnswerRe: SQL command optimization Pin
Michael Flanakin3-Jan-06 3:05
Michael Flanakin3-Jan-06 3:05 
GeneralRe: SQL command optimization Pin
Wjousts3-Jan-06 11:02
Wjousts3-Jan-06 11:02 
AnswerRe: SQL command optimization Pin
Michael Flanakin4-Jan-06 2:26
Michael Flanakin4-Jan-06 2:26 
QuestionNeed help for the trigger Pin
rs_net1-Jan-06 17:52
rs_net1-Jan-06 17:52 
AnswerRe: Need help for the trigger Pin
Colin Angus Mackay2-Jan-06 4:06
Colin Angus Mackay2-Jan-06 4:06 
QuestionPlease, Help me. I am really LOST Pin
alexvw1-Jan-06 14:47
alexvw1-Jan-06 14:47 
AnswerRe: Please, Help me. I am really LOST Pin
Colin Angus Mackay1-Jan-06 15:16
Colin Angus Mackay1-Jan-06 15:16 
GeneralRe: Please, Help me. I am really LOST Pin
alexvw2-Jan-06 2:15
alexvw2-Jan-06 2:15 
GeneralRe: Please, Help me. I am really LOST Pin
Colin Angus Mackay2-Jan-06 2:38
Colin Angus Mackay2-Jan-06 2:38 
GeneralRe: Please, Help me. I am really LOST Pin
alexvw2-Jan-06 2:35
alexvw2-Jan-06 2:35 
AnswerRe: Please, Help me. I am really LOST Pin
S. Akif Kamal1-Jan-06 20:02
S. Akif Kamal1-Jan-06 20:02 
GeneralRe: Please, Help me. I am really LOST Pin
alexvw2-Jan-06 2:17
alexvw2-Jan-06 2:17 
GeneralRe: Please, Help me. I am really LOST Pin
alexvw2-Jan-06 2:35
alexvw2-Jan-06 2:35 
GeneralRe: Please, Help me. I am really LOST Pin
Colin Angus Mackay2-Jan-06 2:40
Colin Angus Mackay2-Jan-06 2:40 
GeneralRe: Please, Help me. I am really LOST Pin
Rob Graham2-Jan-06 4:49
Rob Graham2-Jan-06 4:49 
GeneralRe: Please, Help me. I am really LOST Pin
S. Akif Kamal2-Jan-06 19:26
S. Akif Kamal2-Jan-06 19:26 
Questionado in pascal Pin
aspnet_221-Jan-06 9:09
aspnet_221-Jan-06 9:09 

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.