Retrieve User Push Channel Data by Type - MySQL Query Example
To retrieve the data of a specific user's push channels for each push type, you can use the following SQL query:\n\nsql\nSELECT user_id, \n MAX(CASE WHEN push_type = '1' THEN push_channel END) AS push_channel_type1,\n MAX(CASE WHEN push_type = '2' THEN push_channel END) AS push_channel_type2,\n MAX(CASE WHEN push_type = '3' THEN push_channel END) AS push_channel_type3\nFROM bms_user_push_configuration\nWHERE user_id = 'user1'\nGROUP BY user_id;\n\n\nThis 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.\n\nMake sure to replace 'user1' with the actual user ID you want to retrieve the data for.
原文地址: https://www.cveoy.top/t/topic/qhQR 著作权归作者所有。请勿转载和采集!