This topic is locked

one to many relationship creating duplicate ID column

12/21/2015 12:39:07 PM
PHPRunner General questions
K
krisrianto author

i have a one to many query to be shown as list. This result in the key ID column having duplicates. How do I show each individual item in the view when I click on the list?
Please help me
Kris

Sergey Kornilov admin 12/21/2015

This looks like incorrect foreign key selection. Make sure that you are not selecting details table primary key as a link field while setting up master-details relationship.

K
krisrianto author 12/22/2015



This looks like incorrect foreign key selection. Make sure that you are not selecting details table primary key as a link field while setting up master-details relationship.


The problem is that this is a sql query on the table. I can only choose primary key based on the primary table. However, my query returns multiple ID on primary table because it is one to many. I need to choose a key on the primary key as well as on the subtable to make it unique. Since I can only choose a key on the primary key, there is no option to choose primary key based on a subtable on a query. Do I make sense?
for example:

SELECT

tblformula.formulaid,

tblprice.priceid,

tblprice.packaging

FROM tblprice

RIGHT OUTER JOIN tblformula ON tblformula.basecode = tblprice.BaseCode
Will give

formulaid | priceid | packaging

2230 | 10 | 1L

2230 | 11 | 2L

2231 | 10 | 1L

2231 | 11 | 2L
how do I choose formulaid and priceid together as key because i can only choose formulaid?

K
krisrianto author 12/22/2015

I think i have figured out a work around but i need help. What I am going to do is to insert a $strWhereClause = "tblprice.packagingid = xxx and tblformula.Formulaid = yyy" in the view page event. However, I need to figure out a work around to pass xxx and yyy value from the list page when i click "view" button. What events do i need to do? Can you help me?
Thanks