Remember a very long SQL, in order to facilitate reading, I have added the paragraph:
SELECT * from ( (SELECT 1 asAcheck, S1.id, S1.plan_name, S1.cost_mode, S1.sta_type, S1.cost_type, S1.cost_period_time, S1.cost_period_value, S1. ' Carrier_operator ', S1.cost_settle_type fromWo_serviceplan S1JOINWo_serviceplan_hotspot SH onS1.id=sh.serviceplan_idWHERES1.is_enable= 1 andsh.hotspot_id= 109 ORDER byS1.plan_nameASC ) UNION All (SELECT 2 asAcheck, S2.id, S2.plan_name, S2.cost_mode, S2.sta_type, S2.cost_type, S2.cost_period_time, S2.cost_period_value, S2. ' Carrier_operator ', S2.cost_settle_type fromWo_serviceplan S2WHERES2.is_enable= 1 andS2.id not inch(SELECTserviceplan_id fromWo_serviceplan_hotspotWHERE 1=1 andhotspot_id= 109 ) ORDER byS2.plan_nameASC) ) asS3ORDER byS3.acheckASC, S3.plan_nameASCLIMIT0, -
MySQL Federated Query Union