vendredi 11 septembre 2015

Join a query result set with an existing table in sqlite?

I have a query result set like this:

value | id 
500   | 1
400   | 1
300   | 2

and a product table:

product_name | id 
product_1    | 1 
product_2    | 2 
product_5    | 3
product_6    | 4 
product_9    | 5 
product_0    | 6

Now I want to find the product_name from product table for every row in query result set and join the result to look like following:

The result after joining should be following:

product_name | id | value
product_1    | 1  | 500
product_1    | 1  | 400
product_5    | 2  | 300

I am getting confused how to use left join to achieve the result.

Aucun commentaire:

Enregistrer un commentaire