select ltrim(rtrim(lastname) +','+ rtrim(firstname) +' '+ rtrim(middlename)) as patient_name, rtrim(roomnumber) as room_number, (roomtype) as room_type, (date_admit) as date_of_admission, (bednumber) as number_of_bed from tblconfine e inner join tblpatient p on p.rid= e.patient_id inner join tblroom r on r.rid= e.room_id declare @room_id as bigint,@patient_id as bigint set @room_id= (select rid from tblroom where roomnumber ='301'); set @patient_id= (select rid from tblpatient where lastname ='cornista' and firstname='johnritz'); insert into tblconfine (patient_id,room_id) values (@patient_id,@room_id)
i have 3 tables the tblpatient,tblroom and tblconfine. i can't combine the information in tblpatient and tblroom.
tblpatient fields are rid,firstname,middlename,lastname,contactnumber,e-mail,address,date admitted, while tblroom fields are rid,room number,room type,number of beds,firstname,middlename,lastname,
the tblconfine fields are patient_id,room_id,rid,date_admitted,number_of_bed,address,contact_number,name_of_patient.
if i run this code in sql sever 2005.. there are some columns with null value..
the output must be the name of patient,dateadmitted,room number,number of bed, room type,adress and contact number
This post has been edited by saizburg: 17 September 2012 - 04:02 AM