Table 1:
id | typeid | available|
0 | 1 | 12 |
0 | 2 | 44 |
Table 2:
<
Try this:
SELECT a.id, MAX(IF(b.typename = 'CL', a.available, 0)) CL,
MAX(IF(b.typename = 'ML', a.available, 0)) ML
FROM table1 a
INNER JOIN table2 b ON a.typeid=b.typeid
GROUP BY a.id;
Use SUM function if you want to sum of the data from available column for particualr type else use the same query as ii is.