How to use a select field showing 2 concat fields but showing only one once choosen

It seems complicated but it’s quite easy to understand.

Suppose to have a table with ID, Code, State columns.

When I use a select field on a form I would like to read on match box both Code and State name but when I later choose one of the list I need to show only the Code.
That’s becouse I’ve no space for both in the grid and so I would like to show only the Code.

SELECT ID, sc_concat(Code, " - ", State)
FROM us_states
ORDER BY ID

Now when I choose a row SC insert into field MAS - Massachutes .
What I need is to be able to read “MAS - Massachutes” but once choosen the row I would like to have only
“MAS”
on the form field.

What I have to do to obtein it ?

try select if(id is null,sc_concat(Code, " - ", State) , sc_concat(Code) )
or a variant of this