diff --git a/db/notification_error.db.js b/db/notification_error.db.js index 2ec1500..7648683 100644 --- a/db/notification_error.db.js +++ b/db/notification_error.db.js @@ -14,8 +14,28 @@ const InsertNotificationErrorDb = async (store) => { const getNotificationByIdDb = async (id) => { const queryText = ` SELECT - a.* + a.*, + b.plant_sub_section_id, + c.plant_sub_section_name, + d.device_code, + d.device_name, + d.device_location, + e.brand_name + FROM notification_error a + + LEFT JOIN m_tags b + ON a.error_chanel = b.tag_number + + LEFT JOIN m_plant_sub_section c + ON b.plant_sub_section_id = c.plant_sub_section_id + + LEFT JOIN m_device d + ON b.device_id = d.device_id AND d.deleted_at IS NULL + + LEFT JOIN m_brands e + ON d.brand_id = e.brand_id AND d.deleted_at IS NULL + WHERE a.notification_error_id = $1 AND a.deleted_at IS NULL `; const result = await pool.query(queryText, [id]);