Populating a SQL Table with data from Two other SQL Tables - in the same DB

Hi all.

I’m having a bit of trouble here. I’m a noob when it comes to JS so please bear with me.

I'm trying to generate a product list (basically populate an sql table) with data from two other tables. This is what I’m trying to achieve:

Table 1 - master list of car brands. including make, model, features etc.
Table 2 - list of product pricing bands (ie. SUV Single Item, SUV Triple Item, Hatch Single, Hatch Tripe etc. etc. )
Table 3 – generated SKUs

At the moment I have a query to select data from Table 1 (includes a col called price_band) :

select * from all_vehicles where sku_status = ‘pending’

This is working fine and I could use a loop to populate Table 3 using Key:Value pairs. Issue is, I can’t seem to create a loop to find the corresponding price for each item in that first query.

The closest I’ve got is querying the other table in a loop, but that seems to result in an array of data that I cant format in the Key:Value pair correctly. :

select suv_single from pricing_matrix where banding = {{value.price_band}}

Does anybody have any experience doing something similar? Can’t seem to find many similar use cases out there.

Apologies if I haven’t made myself very clear. I can easily clarify finer points.

Thanks so much!

Hey @jbunting! Just to double check, are you looking to do something like this?