I have this query and like to ask some questions.
$query = "
SELECT
pay,
client,
product,
SUM(pay) AS tot_pay,
COUNT(product) AS count_product
FROM
product p,
result r
WHERE
r.product_id = p.product_id
AND control = 1
AND waste_id IS NULL
GROUP BY product
ORDER BY client";
I have a table result_extra that holds things that can be added to product. If product_id in result_extra is the same as ID(int auto) in product. I want to use that row in result_extra to get strings out of table-extra. So if result.ID = result_extra.result_id I what to fetch columns from extra. Should I get another query to do the extra part, or can it be done in a tidy all-in-one-way?
result
ID(int auto) | product(int) | time | etc
result_extra
result_id(int) | extra_id(int)
extra
extra_id(int) | extra(string) | price(int) | etc
Is it possible to make a understandable table where this all-in-one data in shown? I haven't been able to do that, but that could be my limited sql skill stopping me.