Click here to Skip to main content
15,909,242 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL DATABASE Pin
Hristo-Bojilov13-Aug-09 5:04
Hristo-Bojilov13-Aug-09 5:04 
QuestionCase Sensitive User Name Pin
janani1311-Aug-09 2:38
janani1311-Aug-09 2:38 
AnswerRe: Case Sensitive User Name Pin
Luc Pattyn11-Aug-09 3:30
sitebuilderLuc Pattyn11-Aug-09 3:30 
QuestionHow to change the default port 1433 for SQLServer 2008 Pin
Paramu197311-Aug-09 1:03
Paramu197311-Aug-09 1:03 
AnswerRe: How to change the default port 1433 for SQLServer 2008 Pin
Paramu197311-Aug-09 4:18
Paramu197311-Aug-09 4:18 
QuestionHow to Concate more than one rows in one row ?. Pin
Fazal Vahora10-Aug-09 21:41
Fazal Vahora10-Aug-09 21:41 
AnswerRe: How to Concate more than one rows in one row ?. Pin
infneeta10-Aug-09 23:46
infneeta10-Aug-09 23:46 
QuestionOuter Join issues Pin
Mustafa Ismail Mustafa10-Aug-09 4:45
Mustafa Ismail Mustafa10-Aug-09 4:45 
I have two tables that share two columns:

Table 1:

Name: EMR.mmPatientAdmissionSymptoms
Columns: PatientID, AdmittanceID,SymptomID

Table 2:

Name: EMR.mmPatientAdmissionSymptomsOther
Columns: PatientID, AdmittanceID,Symptom

EMR.mmPatientAdmissionSymptoms.SymptomID is an integer whilst EMR.mmPatientAdmissionSymptomsOther.Symptom is nvarchar(MAX).

Now, I want to pull all the data in both tables, where the data in either table not existing being null. That should be a straight full outer join, right?

SELECT	
	pas.PatientID, pas.AdmittanceID, pas.SymptomID, paso.Symptom
FROM         EMR.mmPatientAdmissionSymptoms as pas full outer join
                      EMR.mmPatientAdmissionSymptomsOther as paso 
                      on pas.PatientID = paso.PatientID
                      AND pas.AdmittanceID = paso.AdmittanceID


But it doesn't; It seems to preform a cross join. Out of frustration I tried left, right, cross and inner joins just to see if I'm on the right track or not. They ALL give the same result



Scripts if you want to try this: (altered slightly so you don't have to remove the FK and Schemas)
-- Table 1
CREATE TABLE [mmPatientAdmissionSymptoms](
	[PatientID] [char](10) NOT NULL,
	[AdmittanceID] [int] NOT NULL,
	[SymptomID] [int] NOT NULL,
 CONSTRAINT [PK_mmPatientAdmissionSymptoms] PRIMARY KEY CLUSTERED 
(
	[PatientID] ASC,
	[AdmittanceID] ASC,
	[SymptomID] ASC
)

--Table 2
CREATE TABLE [EMR].[mmPatientAdmissionSymptomsOther](
	[PatientID] [char](10) NOT NULL,
	[AdmittanceID] [int] NOT NULL,
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Symptom] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_mmPatientAdmissionSymptomsOther] PRIMARY KEY CLUSTERED 
(
	[PatientID] ASC,
	[AdmittanceID] ASC,
	[ID] ASC
)
--ID is an Identity field so that I can differentiate between one entry and the other for each patient at each admittance


Results are returned as:

PatientID AdmittanceID SymptomID Symptom
============================================================
1234 1 1 This is a symptom
1234 1 3 This is a symptom


Table 1:

PatientID AdmittanceID SymptomID
==============================================
1234 1 1
1234 1 3



Table 2:

PatientID AdmittanceID ID Symptom
====================================================================
1234 1 1 This is a symptom



One final note, there are no FK relations between the two tables

If the post was helpful, please vote, eh!

Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ

Now and forever, defiant to the end.
What is Multiple Sclerosis[^]?

AnswerRe: Outer Join issues Pin
leckey10-Aug-09 5:26
leckey10-Aug-09 5:26 
GeneralRe: Outer Join issues Pin
Mustafa Ismail Mustafa10-Aug-09 5:44
Mustafa Ismail Mustafa10-Aug-09 5:44 
GeneralRe: Outer Join issues Pin
DoctorMick10-Aug-09 6:28
DoctorMick10-Aug-09 6:28 
GeneralRe: Outer Join issues Pin
Mustafa Ismail Mustafa10-Aug-09 9:34
Mustafa Ismail Mustafa10-Aug-09 9:34 
GeneralRe: Outer Join issues Pin
i.j.russell10-Aug-09 8:12
i.j.russell10-Aug-09 8:12 
GeneralRe: Outer Join issues Pin
Mustafa Ismail Mustafa10-Aug-09 9:41
Mustafa Ismail Mustafa10-Aug-09 9:41 
GeneralRe: Outer Join issues Pin
leckey10-Aug-09 8:38
leckey10-Aug-09 8:38 
Questioncustom query Pin
sujithkumarsl9-Aug-09 23:45
sujithkumarsl9-Aug-09 23:45 
AnswerRe: custom query Pin
Mycroft Holmes10-Aug-09 3:04
professionalMycroft Holmes10-Aug-09 3:04 
GeneralRe: custom query Pin
Luc Pattyn10-Aug-09 3:34
sitebuilderLuc Pattyn10-Aug-09 3:34 
QuestionConnection String Pin
John.L.Ponratnam9-Aug-09 23:34
John.L.Ponratnam9-Aug-09 23:34 
AnswerRe: Connection String Pin
SeMartens10-Aug-09 0:31
SeMartens10-Aug-09 0:31 
Questionlost data base Pin
Tauseef A9-Aug-09 23:09
Tauseef A9-Aug-09 23:09 
AnswerRe: lost data base Pin
SeMartens10-Aug-09 0:33
SeMartens10-Aug-09 0:33 
QuestionDTS to Import .SQL file Pin
Paul Hayman9-Aug-09 22:28
Paul Hayman9-Aug-09 22:28 
AnswerRe: DTS to Import .SQL file Pin
Mycroft Holmes10-Aug-09 3:08
professionalMycroft Holmes10-Aug-09 3:08 
GeneralRe: DTS to Import .SQL file Pin
Paul Hayman10-Aug-09 18:21
Paul Hayman10-Aug-09 18:21 

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.