To retrieve the data of a specific user's push channels for each push type, you can use the following SQL query:

SELECT user_id, 
    MAX(CASE WHEN push_type = '1' THEN push_channel END) AS push_channel_type1,
    MAX(CASE WHEN push_type = '2' THEN push_channel END) AS push_channel_type2,
    MAX(CASE WHEN push_type = '3' THEN push_channel END) AS push_channel_type3
FROM bms_user_push_configuration
WHERE user_id = 'user1'
GROUP BY user_id;

This query uses conditional aggregation (CASE statement) to pivot the push channels based on their corresponding push types. Each push type has its own column (push_channel_type1, push_channel_type2, push_channel_type3) in the result set.

Make sure to replace 'user1' with the actual user ID you want to retrieve the data for

CREATE TABLE bms_user_push_configuration id bigint20 NOT NULL COMMENT 唯一标识 user_id varchar20 DEFAULT NULL COMMENT 燃气用户号 user_name varchar200 DEFAULT NULL COMMENT 户名 push_type varchar20 DEFAUL

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

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