mysql join statement

Dear Experts,
I use MySQL and PHP.
I have a column in table1 which shows the price of my product, on the second table I have the number of the product.
I use below select statement, it brings me all the information I need.
However I want to add one more column for the total price.
I want to see (price*number) as totalprice on my table?

How can I do that? Thank you

SELECT * FROM table1 t
INNER JOIN
( SELECT id,adet FROM table2 ) p
ON p.id = t.id;

Open in new window

LVL 1
BRMarketingAsked:
Who is Participating?
 
Ryan ChongConnect With a Mentor Commented:
try:

SELECT
t.*, p.*, t.price* p.cnt Total
FROM table1 t
INNER JOIN
( SELECT id,adet, count(id) cnt FROM table2 group by id,adet) p
ON p.id = t.id;

Open in new window

2
 
BRMarketingAuthor Commented:
Thank you Ryan Chong
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.