How to Use Sub Query In SQL

SELECT 
    od.`product_id`,
    SUM(od.`origianl_quantity`) AS total_quantity,
    (SELECT pro.`name` FROM products AS pro WHERE pro.`id` = od.`product_id`) 
        AS product_name 
FROM order_details AS od 
        GROUP BY od.`product_id`  ORDER BY total_quantity DESC

Popular posts from this blog

Yii Framework In Update Time View Image In Form

Add a new column to existing table in a migration

Ajax Toggle(on/off) on-click Update