Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Creating a summary table using sql

Featured Replies

Hello, I am kinda of new to filemaker but I was reading up on some sql in FMP 12 and came across a virtual table concept. I currently am doing a database for a cancer clinic which contains 4 tables. the tables are named "Main", "Treatment", "Diagnosis" and "lab". treatment, diagnosis and lab are all related to Main. (__pk_Main=__fk_Main). I want to create a summary table that will extract the Treatment, diagnosis and lab records for each patient in "main" and then display it on a portal. Will sql be able to make this virtual table?

Yes, absolutely you can do that by using the Execute SQL function in FileMaker12. For example you want to show all related diagnosis, treatment and lab reports of a particular patient. Suppose the key serial of the patient is 101 i.e. __pk_Main = 101. And you have attached a patient list to a global field (say gPatientID) then the list of info you want to display for the selected patient should be like the following.

 

//Treatments details

ExecuteSQL ( "SELECT TreatmentInfo FROM Treatments WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

//Diagnosis details

ExecuteSQL ( "SELECT DiagnosisInfo FROM Diagnosis WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

// Pathological/Lab reports

ExecuteSQL ( "SELECT TestsInfo FROM Lab WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

 

You can create different fields for each details or you can append all the details into 1 calculation field and display the same.

 

In case you want to so these data in portals with different tabs then what you will do is collect IDs from related tables instead of info and use that IDs to relate the records from respective and show the portals records.

 

 

with regards,

  • Author

Yes, absolutely you can do that by using the Execute SQL function in FileMaker12. For example you want to show all related diagnosis, treatment and lab reports of a particular patient. Suppose the key serial of the patient is 101 i.e. __pk_Main = 101. And you have attached a patient list to a global field (say gPatientID) then the list of info you want to display for the selected patient should be like the following.

 

//Treatments details

ExecuteSQL ( "SELECT TreatmentInfo FROM Treatments WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

//Diagnosis details

ExecuteSQL ( "SELECT DiagnosisInfo FROM Diagnosis WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

// Pathological/Lab reports

ExecuteSQL ( "SELECT TestsInfo FROM Lab WHERE __fk_Main = " & gPatientID; "" ; "¶")

 

 

You can create different fields for each details or you can append all the details into 1 calculation field and display the same.

 

In case you want to so these data in portals with different tabs then what you will do is collect IDs from related tables instead of info and use that IDs to relate the records from respective and show the portals records.

 

 

with regards,

Thank you so much for the reply. I get the idea. So what I want to do is display some fields from Lab, treatment, and diagnoses all in one portal so that the doctors can see how each patient is doing. Every table has a date field and I want to sort the entries by date. I can see how sql would work to join all of the tables together. How many records do I have to allow in order to show this info. Do I need a new record per patient? or just one record per table. For example one record for treatment and one for lab, one for diagnosis? Thanks so much

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.