Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Making the execution optional

$
0
0
Hello all,

I am using sql server management studio 2012. Please tae a minute or two to understand this problem, It's really important:(
The scenario is :
I have three table, Patient, patientAccount and Message.
Now, I am inserting values into tables Patient and Message first, and then after some time I am inserting values into PatientAccount Table.Now, the problem is in the software i am using sql with) i had this query:

select * from Patient join Message on Patient.GUID = Message.PatientGUID where Message.GUID = "..Data

and if I add PatientAccount in this query as well, like 

select * from Patient join Message on Patient.GUID = Message.PatientGUID, PatientAccount where Message.GUID = "..Data

It becomes mandatory to add values to the PatientAccount table at the same moment when I am adding them to Patient and Message table, but what I really want is values to be taken up by query if there is data in the PatientAccount table, and if there is no values inserted into patientAccount table, It should pick up values from Patient and Message table only.
and I want all of it in one query. 

Please please please help :(

Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>