Mcbaloo Mcbaloo - 1 year ago 59
SQL Question

Using Sql to get result from two tables


1 DDU 2
2 FDK 4
3 DDU 3


2 600
3 400
4 500

After the query, This is how i want my table to look like

name amount
DDU 1000

Note: The 1000 for DDU IS GOTTEN BY ADDING 600 AND 400. How do i achieve this using my sql query. Partid is a foreign key in Table1 and Primary Key of table2

Answer Source
FROM Table1 t
JOIN Table2 s
 ON(t.partid = s.partid)

You also should get FDK 500 in your result set , so I assume you need a WHERE clause ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download