一.数据库数据数据
deed_records
sport_records
match_ticket_record
二.sql语句
SELECT d.integral , CASE WHEN d.deed_type=1 THEN (SELECT s.user_id FROM sport_records s WHERE s.id=d.record_id)
WHEN d.deed_type=2 THEN (SELECT m.user_id FROM match_ticket_record m WHERE m.id=d.record_id)
when d.deed_type=3 then (SELECT u.id from users u INNER JOIN vp_situation v on u.openId=v.vps_vpid WHERE u.id=d.record_id)END id,
CASE WHEN d.deed_type=1 THEN '扫码入场' WHEN d.deed_type=2 THEN '买票' WHEN d.deed_type=3 THEN '投票' WHEN d.deed_type=4 THEN '注册' WHEN d.deed_type=5 THEN '购物' END type
FROM deed_records d having id =151;
三.结果