<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[My Visual Database — Create report using data from multiple tables.]]></title>
		<link>https://myvisualdatabase.com/forum/viewtopic.php?id=6984</link>
		<atom:link href="https://myvisualdatabase.com/forum/extern.php?action=feed&amp;tid=6984&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Create report using data from multiple tables..]]></description>
		<lastBuildDate>Sun, 04 Oct 2020 09:15:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38391#p38391</link>
			<description><![CDATA[<p>Hi Brian,<br />It&#039;s an eye-opener. Now the desired report is generated. I&#039;m so happy.<br />Thanks a ton.<br />Eyeman</p>]]></description>
			<author><![CDATA[null@example.com (eyeman303)]]></author>
			<pubDate>Sun, 04 Oct 2020 09:15:20 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38391#p38391</guid>
		</item>
		<item>
			<title><![CDATA[Re: Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38389#p38389</link>
			<description><![CDATA[<div class="quotebox"><cite>eyeman303 wrote:</cite><blockquote><p>Hello,<br />I&nbsp; have almost generated the desired report using Report(Sql) option. I&#039;m stuck at one point. I want to include the Select_Eye for the Complaints also. But since Select_Eye is a foreign key to both aa_004_clinics and aa_003_complaints, there appears an error message &quot;ambiguous Select_Eye...&quot;.How can the eye of complaint and diagnosis be selected? Do I need separate lookup tables for Complaint_Eye and Diagnosis_Eye?<br />Regards,<br />Eyeman</p></blockquote></div><p>I don&#039;t have time to check on the details but for the Report SQL, all you have to do to avoid that ambiguous error is to explicitly select each Select_Eye with their corresponding Table. Here&#039;s a sample to join <strong>lu_004_Select_Eye</strong> named as <strong>CE</strong> and then explicitly select the two Select_Eye Fields that is in same table lu_004_Select_Eye but in different name(<strong>CE and E</strong>) and joined to separate table <strong>clinic </strong>and <strong>complaints</strong>. Hope this gives you an idea<br /></p><div class="codebox"><pre><code>SELECT
V.id, OPD_ID, Date,
First_Name,Last_Name, PID ,

doctor, complaints ,diagnosis , E.Select_Eye as SE_Diagnosis, CE.Select_Eye as SE_Complaints 

FROM                                               
aa_002_opd_visits V                                           
                                    
INNER JOIN    
aa_001_patients P  ON  V.id_aa_001_patients = P.id

INNER JOIN
lu_001_doctors D  ON  V.id_lu_001_doctors = D.id        

INNER JOIN                                                 
aa_004_clinics C ON  C.id_aa_002_opd_visits = V.id

INNER JOIN               
lu_003_diagnosis G ON G.id = C.id_lu_003_diagnosis 

INNER JOIN
lu_004_Select_Eye E ON E.id = C.id_lu_004_Select_Eye

INNER JOIN
aa_003_complaints  M ON   M.id_aa_002_opd_visits = V.id  

INNER JOIN           
lu_004_Select_Eye CE ON CE.id=M.id_lu_004_Select_Eye

INNER JOIN      
lu_002_complaints  LM ON LM.id = M.id_lu_002_complaints 


 where
 V.id = $id</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (brian.zaballa)]]></author>
			<pubDate>Sun, 04 Oct 2020 08:21:09 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38389#p38389</guid>
		</item>
		<item>
			<title><![CDATA[Re: Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38387#p38387</link>
			<description><![CDATA[<p>Hello,<br />I&nbsp; have almost generated the desired report using Report(Sql) option. I&#039;m stuck at one point. I want to include the Select_Eye for the Complaints also. But since Select_Eye is a foreign key to both aa_004_clinics and aa_003_complaints, there appears an error message &quot;ambiguous Select_Eye...&quot;.How can the eye of complaint and diagnosis be selected? Do I need separate lookup tables for Complaint_Eye and Diagnosis_Eye?<br />Regards,<br />Eyeman</p>]]></description>
			<author><![CDATA[null@example.com (eyeman303)]]></author>
			<pubDate>Sun, 04 Oct 2020 07:39:34 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38387#p38387</guid>
		</item>
		<item>
			<title><![CDATA[Re: Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38277#p38277</link>
			<description><![CDATA[<p>Hello Derek,<br />Thanks for your insights. I have made the OPD_ID as the main link for the tables aa_03_complaints and_ aa_04_clinics. I might include diagnosis within the aa_03_complaints table, but I would like to include other details like History, Glass Power, Medications, Advice etc linked to each OPD_ID. In the original project, I have created sub-forms for each of this and stored them in separate tables. As you have mentioned, I would need a main report with related sub-reports. How to create the same?<br />Regards,<br />Eyeman</p>]]></description>
			<author><![CDATA[null@example.com (eyeman303)]]></author>
			<pubDate>Sun, 27 Sep 2020 18:44:10 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38277#p38277</guid>
		</item>
		<item>
			<title><![CDATA[Re: Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38271#p38271</link>
			<description><![CDATA[<p>Hello Eyeman,<br />I had a quick look at your download but wasn&#039;t sure about a couple of things.<br />1.&nbsp; Don&#039;t you need to have a &#039;complaint&#039; (aa_03_complaint) before you can offer a diagnosis (aa_04_clinic)?&nbsp; Yet there is no relationship between the aa_03_complaint and aa_04_clinic tables.<br />2.&nbsp; It appears from the data, that for every complaint, there should be a diagnosis (ie a 1:1 relationship).&nbsp; If that&#039;s the case, is there any advantage in having the aa_04_clinics table at all - it could just all be held on aa_03_complaints.<br />If either 1) or 2) or both of the above is true, then it makes your report pretty simple to write.<br />But as it stands (without changing your data structure), I think you will need a main report (for the &#039;patient&#039; and &#039;OPD&#039; information) and then 2 sub reports (for the &#039;complaints&#039; and the &#039;clinics&#039; information).&nbsp; I&#039;ve little experience of using FastReport but I think that would entail creating the report datasets by script which is a lot less straightforward.<br />Just my view - others may see different ways to address the problem.<br />Derek.</p>]]></description>
			<author><![CDATA[null@example.com (derek)]]></author>
			<pubDate>Sat, 26 Sep 2020 16:40:21 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38271#p38271</guid>
		</item>
		<item>
			<title><![CDATA[Create report using data from multiple tables.]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=38196#p38196</link>
			<description><![CDATA[<p>Hello!<br />I need to create a report containing data from multiple tables, all tables, linked to a single table by a common field. I tried the Report command and ReportSql but failed to configure properly. I have attached a smaller project created from the original project for easier understanding. The report needs to include PID, First_Name, Last_Name, OPD_ID, Date, Complaints, Eyes complaining about, Doctor, Diagnosis, Eye related to diagnosis Please help.</p>]]></description>
			<author><![CDATA[null@example.com (eyeman303)]]></author>
			<pubDate>Mon, 21 Sep 2020 17:18:37 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=38196#p38196</guid>
		</item>
	</channel>
</rss>
