Displaying results from multiple DB queries in 1 table

Hi all,
I have a relational database, where cells in 1 table reference cells in another table through the use of IDs. I want to display some of this data in xGrid, but I don’t want to show IDs, I want to show the values of the cells that the IDs are referencing. How can I achieve this in 1 xGrid table?

For example…

Table “apples” has 3 columns: appleID, appleName, appleBrandID

1, apple1, 1 2, apple2, 1 3, apple3, 2 4, apple4, 2

Table “brands” has 2 colums: brandID, brandName

1, brand1 2, brand2

What I want to show in xGrid is 2 columns: appleName, brandName (of that apple)
eg

apple1, brand1 apple2, brand1 apple3, brand2 apple4, brand2

The only way I know of doing this is to run 1 query to select all appleName & appleBrandID and then for each appleBrandID run a query and fetch the brandName.

Any ideas how I can get there?
Is there a clever SQL query that lets me combine all my queries into 1?
If not, can I replace the appleBrandIDs with BrandNames before the data is sent to xGrid?
If not, can I display the results of multiple queries in 1 xGrid table?

Are you using dhtmlxConnector extension or custom server side code?
In case of dhtmlxConnectors you can use render_sql method to join 2 tables. Please check tutorial here docs.dhtmlx.com/doku.php?id=dhtm … operations

docs.dhtmlx.com/doku.php?id=dhtm … ex_updates

I was using the connector. Problem solved! Thanks :slight_smile: