mySQL PHPmyadmin, grabbing from multiple tables

Let's say I have 2 tables. Table 1 contains 2 columns. ID_1 and ID_2. Table 2 has 4 Columns. Name_ID_1, Name_ID_2, Product, Amount.

What I want to do, is select Name_ID_1, Name_ID_2, Product, sum( Amount ) from Table 2 where Name_ID_1 is = to Table 1.ID_1 in my current table, Table 2.

The end result I want is the sum of Amount per Product per Name_ID_2 where Table 2's Name_ID_1 = Table 1.ID_1. The code below is returning 0 results.

SELECT `Product`,`Name_ID_2`,`Name_ID_1`, sum( `Amount` ) 
FROM Table 2 
WHERE 'Name_ID_1' = 'Table 1.ID_1'
GROUP BY `Name_ID_2`

End results desired look like this...

Corn|JIM|Corn Company|100

Soy|JIM|Soy Company|200

Corn|Jack|Corn Company|100

Soy|Jack|Soy Company|100

Answers


SELECT `Product`,`Name_ID_2`,`Name_ID_1`, sum( `Amount` ) as Amount
FROM Table2 inner join Table1 on `Table2`.`Name_ID_1` = `Table1`.`ID_1`
GROUP BY `Name_ID_2`

Need Your Help

How do I access an ASP.NET variable to pass as JSON string to WCF Ajax Enabled Service

jquery asp.net ajax json wcf

I have a WCF AJAX enabled web service, and I am trying to pass a value of a field in an ASP.NET page into it with JSON but I always get nothing f. I want to do something like what we did in ASP.NET...