Hi all
I am new to the list and have a slight problem which I hope you experts can solve. I am a pharmacist doing a project. I have three tables 1. A patient table with the patient details 2. A Pharmaceutical drug table with drug names and dosage and other data. 3. A Patient history record with the drug names and dosages. The patient and history table are linked by a master-detail relationship. I have set up a search on the drug table to look up the drug names etc, but after I have found the drug how do I insert the values of the name and dosage into the patient history table. I hope some one can help. Many Thanks Hilton Gowar ------------------------------ Message: 2 Date: Wed, 18 Oct 2006 21:37:40 -0500 From: "Ralph D. Wilson II" <[EMAIL PROTECTED]> Subject: Re: re inserting fields To: Delphi-Talk Discussion List <delphi-talk@elists.org> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii"; format=flowed Hilton, Actually, you can accomplish the whole package in one SQL UPDATE statement. Something along the lines of UPDATE Patient_History SET Drug_Name {place you select query here}; Essentially it needs to have the following basic format: UPDATE Patient_History SET colx = ( SELECT Drugs.Name AS Drug_Name FROM Drugs WHERE Drugs.DrugID=Patient_History.DrugID ) On the other hand, you can accomplish the same thing with a join to the Drug table when you need it and you don't consume the extra space in the database for all those duplicated drug names. _____________________________________________________________________ Futher explaination Thanks for the reply, I will try that, but I am looking for something similar to the mastapp example in delphi where the part number is selected from a search dialog and selected and then inserted into a orders grid. I have studied the code for this example but as the other bits of code have no bearing on what I am trying to accomplish it is a bit confusing. Hope this explains my problem a bit better. Many Thanks Hilton Gowar __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@elists.org http://www.elists.org/mailman/listinfo/delphi-talk