Skip to main content
vaddhicharanc0001
March 30, 2022
Question

Combine two database tables

  • March 30, 2022
  • 9 replies
  • 0 views

Hi Readers,

I have two tables

Table-A with columns:- ID_A, Job_Role, Company_Name
Table-B with columns:- Member_ID, Name, PhoneNumber, ID_A

which are related as one to many relations

I have created record type for different these tables and added relation ships in the record type as well, Would like to know can we consolidate them as below requirement

rows which i want to display are 

Member_ID Job_Role Company_Name Name Phone_Number
1 DBA ABC.ltd SSR 1234567890
2 DBA ABC.ltd RC 0987654321
3 SysAdmin ABC.ltd NTR 6789054321
4 SysAdmin ABC.ltd RRR 1234567098
5 HR ABC.ltd MB 0984562348

Below are the tables structure


Table-A is as below

ID_A(PK) Job_Role Company_Name
1 DBA ABC.ltd
2 SysAdmin ABC.ltd
3 HR ABC.ltd

Table - B is as below

Member_ID Name Phone_Number ID_A(FK)
1 SSR 1234567890 1
2 RC 0987654321 1
3 NTR 6789054321 2
4 RRR 1234567098 2
5 MB 0984562348 3

9 replies

harshitb6843
March 30, 2022

Yes. That is possible. 
In a local variable, you the query record type and use the output in the grid. 
You will be able to access the related fields of the record by accessing its relationships. ie. recordType!Member.relationships.relatedRecord.fields.fieldName

peter.lewis
Employee
March 30, 2022

Since the grid you're looking for has one row per member, I'd suggest making the record type for table B your source for the grid. Then, you can reference fields from table a by using relationship references. For example, you can select the job role by referencing the field recordType!A.relationships.B.jobRole.

If you're still having troubles, can you post your code and any errors / issues that are occurring?

vinaykumarp8308
Participating Frequently
March 31, 2022

Yes [mention:9f33495a4fc04840b5451dfb3f9c66ea:e9ed411860ed4f2ba0265705b8793d05], it is possible. Apart from the above mentioned solutions, you can even create a view in database as per the requirement.

And create a record to retrieve data from that view. Hope this helps !!

vaddhicharanc0001
March 31, 2022

We can create a view from multiple tables and how can we use that ??

vinaykumarp8308
Participating Frequently
March 31, 2022

Create a record Type object for that view as you do for a table and then use it in the grid as required.