Click here to Skip to main content
15,914,071 members
Home / Discussions / Database
   

Database

 
AnswerRe: transfering data Pin
Leah_Garrett21-Nov-06 18:11
Leah_Garrett21-Nov-06 18:11 
Questiondata integrity using triggers check date Pin
drequinox21-Nov-06 7:38
drequinox21-Nov-06 7:38 
AnswerRe: data integrity using triggers check date Pin
Chris Meech21-Nov-06 8:11
Chris Meech21-Nov-06 8:11 
AnswerRe: data integrity using triggers check date Pin
Eric Dahlvang21-Nov-06 10:13
Eric Dahlvang21-Nov-06 10:13 
GeneralRe: data integrity using triggers check date Pin
drequinox21-Nov-06 11:11
drequinox21-Nov-06 11:11 
QuestionRe: data integrity using triggers check date Pin
drequinox21-Nov-06 11:12
drequinox21-Nov-06 11:12 
GeneralRe: data integrity using triggers check date Pin
Pete O'Hanlon21-Nov-06 22:57
mvePete O'Hanlon21-Nov-06 22:57 
QuestionHelp with SQL query!!! Pin
bazpaul21-Nov-06 4:51
bazpaul21-Nov-06 4:51 
Hey everyone! I have been scouring the internet for help on an SQL query i need to run and have been trying for a day or two now to no avail! Can any SQL heroes please help me???

My problem seems simple but may not be so! In this example i have two tables, with their respective columns beside in brackets!

1. SERVERS (ID, NAME, LOCATION, OS)
2. SERVERS_VM (PHYSICAL_ID, VIRTUAL_ID)


The columns ID, PHYSICAL_ID and VIRTUAL_ID are all primary keys!

Now consider that the SERVERS table contains lots of servers both physical and virtual each with their own unique primary key labelled ID. While the SERVERS_VM table contains a list of all physical servers that have virtual servers installed on them! So each PHYSICAL_ID in SERVERS_VM might have one or more VIRTUAL_ID's associated with it.

Below i will try to give an example;

SERVERS
-------------------------------------------
ID Name Location o/s
-------------------------------------------
1 Bob12 BobOffice Win Server
23 Ash14 AshOffice Virtual
7 Hank89 Hankoffice Win Server
14 Tom98 Tomoffice Virtual
8 Mark45 Markoffice Win Server
93 Bar123 Baroffice Virtual


SERVERS_VM
---------------------------
PHYSICAL_ID VIRTUAL_ID
---------------------------
7 23
8 14
7 93


Ok so, now not trying to confuse people, but if we see above, Ash14 tom98 and bar123 are virtual servers (os=virtual) located on physical servers (shown in servers_vm)

From SERVERS_VM we can see that server number 7 houses two virtual servers given by their VIRTUAL_ID which is the same as the ID i the SERVERS table! (23 & 93)

So heres is the big question? How can i run an SQL query to list all the physical servers that have virtual servers alone installed on them??

The results should be something like;

---------------------------------------------
ID NAME VIRTUAL_ID
---------------------------------------------
7 Hank89 23
7 Hank89 93
8 Mark45 14


the problem is the fact that there are two primary keys in the SERVERS_VM table, well even though the PHYSICAL_ID repeats in the SERVERS_VM table


this is what i have so far;

SELECT PHYSICAL_ID, VIRTUAL_ID FROM (SELECT ID, NAME FROM SERVERS WHERE OS like '%Virtual%') WHERE SERVERS.ID=SERVERS_VM.VIRTUAL_ID

i have gone to much more depth but dont want to post it up because it is really messy.


Can anyone please Help??????
AnswerRe: Help with SQL query!!! Pin
Farhan Noor Qureshi21-Nov-06 4:58
Farhan Noor Qureshi21-Nov-06 4:58 
GeneralRe: Help with SQL query!!! Pin
bazpaul21-Nov-06 5:00
bazpaul21-Nov-06 5:00 
AnswerRe: Help with SQL query!!! Pin
Eric Dahlvang21-Nov-06 9:53
Eric Dahlvang21-Nov-06 9:53 
QuestionStore Proc Problem Pin
tthellebuyck21-Nov-06 4:49
tthellebuyck21-Nov-06 4:49 
AnswerRe: Store Proc Problem Pin
Leah_Garrett21-Nov-06 17:51
Leah_Garrett21-Nov-06 17:51 
GeneralRe: Store Proc Problem Pin
tthellebuyck22-Nov-06 3:15
tthellebuyck22-Nov-06 3:15 
QuestionUnable to update the record. Pin
Arun Hegde21-Nov-06 3:58
Arun Hegde21-Nov-06 3:58 
AnswerRe: Unable to update the record. Pin
Colin Angus Mackay21-Nov-06 4:27
Colin Angus Mackay21-Nov-06 4:27 
QuestionHow to creat the registration form for Acces Pin
lopa1221-Nov-06 3:32
lopa1221-Nov-06 3:32 
AnswerRe: How to creat the registration form for Acces Pin
Paul Conrad21-Nov-06 19:39
professionalPaul Conrad21-Nov-06 19:39 
QuestionCreating a database Pin
Christer Claesson21-Nov-06 1:17
Christer Claesson21-Nov-06 1:17 
AnswerRe: Creating a database Pin
ChandraRam21-Nov-06 1:48
ChandraRam21-Nov-06 1:48 
AnswerRe: Can't connect to Mysql "godaddy" Pin
Paul Conrad21-Nov-06 19:41
professionalPaul Conrad21-Nov-06 19:41 
GeneralRe: Can't connect to Mysql "godaddy" [modified] Pin
Samuel G21-Nov-06 20:14
Samuel G21-Nov-06 20:14 
GeneralRe: Can't connect to Mysql "godaddy" Pin
Paul Conrad21-Nov-06 20:57
professionalPaul Conrad21-Nov-06 20:57 
GeneralRe: Can't connect to Mysql "godaddy" Pin
Samuel G21-Nov-06 21:29
Samuel G21-Nov-06 21:29 
QuestionError While importing Excel file in to Sql server 2005. Pin
srinivasintouch20-Nov-06 23:03
srinivasintouch20-Nov-06 23:03 

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.