fix: join table name

This commit is contained in:
2025-10-14 11:02:04 +07:00
parent 110c73ae9d
commit 2c295ffd36

View File

@@ -59,7 +59,7 @@ const getAllTagsDb = async (searchParams = {}) => {
c.sub_section_name c.sub_section_name
FROM m_tags a FROM m_tags a
LEFT JOIN m_device b ON a.device_id = b.device_id LEFT JOIN m_device b ON a.device_id = b.device_id
LEFT JOIN m_plant_subsection c ON a.sub_section_id = c.sub_section_id LEFT JOIN m_plant_sub_section c ON a.sub_section_id = c.sub_section_id
WHERE a.deleted_at IS NULL WHERE a.deleted_at IS NULL
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}
${whereOrConditions ? ` ${whereOrConditions}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""}
@@ -87,7 +87,7 @@ const getTagsByIdDb = async (id) => {
c.sub_section_name c.sub_section_name
FROM m_tags a FROM m_tags a
LEFT JOIN m_device b ON a.device_id = b.device_id LEFT JOIN m_device b ON a.device_id = b.device_id
LEFT JOIN m_plant_subsection c ON a.sub_section_id = c.sub_section_id LEFT JOIN m_plant_sub_section c ON a.sub_section_id = c.sub_section_id
WHERE a.tag_id = $1 AND a.deleted_at IS NULL WHERE a.tag_id = $1 AND a.deleted_at IS NULL
`; `;
const result = await pool.query(queryText, [id]); const result = await pool.query(queryText, [id]);