Answer the question
In order to leave comments, you need to log in
How to make a selection from two tables?
There is a table gamefication
In it the list of all "tasks" for users.
There is a customer_gamefication table
. It stores the id of users who have completed some of the tasks.
I need to display all the data from the gamefication table (All tasks) and enter matches with customer_gamefication for a specific user (customer_id)
I tried to do it and everything came out correctly, but other users got into the result, although I specified WHERE customer_id
Answer the question
In order to leave comments, you need to log in
I found a solution
SELECT
g.id, g.step_id, g.name, cg.customer_id, cg.status, cg.date_added FROM oc_gamefication g
LEFT JOIN oc_customer_gamefication cg ON (g.id = cg.gamefication_id AND cg.customer_id = 26854)
And why are you afraid of a flat request???
SELECT g.step_id, g.name, cg.status, cg.date_added
FROM oc_gamefication g, oc_customer_gamefication cg
WHERE g.customer.id = 26854 AND g.id = cg.gamefication_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question