How to hide a column in output result in Mysql?

Zajjith Vedha :
select historic_betfair_win_prices.sf_name,historic_runners.finish_position,historic_runners.official_rating,historic_betfair_win_prices.date, historic_betfair_win_prices.bsp,
         if(finish_position = 1 , @b:=@b+1,@b:=@b) opening_position,
         if(finish_position = 1 , @last_op:=official_rating,@last_op:=@last_op)last_opening_position,
         cast(if(@b = 0 or finish_position = 1,0,@last_op - official_rating) as decimal(10,2)) diff
from historic_runners
inner join historic_betfair_win_prices on historic_betfair_win_prices.runner_id = historic_runners.runner_id and historic_betfair_win_prices.sf_race_id = historic_runners.race_id
cross join (select @b:=0, @last_op :=0) b
where historic_betfair_win_prices.sf_name = "Camanche Grey"
limit 50

I want to hide

opening_position, last_opening_position

columns from the output result. My Mysql version 8.0.18

Fahmi :

Use a subquery

select sf_name,finish_position,official_rating,date,bsp,diff from
(
select historic_betfair_win_prices.sf_name,historic_runners.finish_position,historic_runners.official_rating,historic_betfair_win_prices.date, historic_betfair_win_prices.bsp,
         if(finish_position = 1 , @b:=@b+1,@b:=@b) opening_position,
         if(finish_position = 1 , @last_op:=official_rating,@last_op:=@last_op)last_opening_position,
         cast(if(@b = 0 or finish_position = 1,0,@last_op - official_rating) as decimal(10,2)) diff
from historic_runners
inner join historic_betfair_win_prices on historic_betfair_win_prices.runner_id = historic_runners.runner_id and historic_betfair_win_prices.sf_race_id = historic_runners.race_id
cross join (select @b:=0, @last_op :=0) b
where historic_betfair_win_prices.sf_name = "Camanche Grey"
limit 50
)A

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=8464&siteId=1