This SQL query selects all columns from the "m_single_phase_machine_device" table and adds a new computed column "deviceName" that is retrieved from the "m_device" table by matching the "DEVICE_NO" column in both tables. The result set is then sorted by the "CREATE_DATE" column in descending order.

The "LEFT JOIN" keyword is used to include all rows from the "m_single_phase_machine_device" table, even if there is no matching row in the "m_device" table. If there is no match, the value of the "deviceName" column will be NULL

SELECT mspmd deviceDEVICE_NAME AS deviceNameFROM m_single_phase_machine_device mspmd LEFT JOIN m_device device ON deviceDEVICE = mspmdDEVICE_NOORDER BY mspmdCREATE_DATE DESC

原文地址: https://www.cveoy.top/t/topic/f6XA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录