N
N
Nikolai Novosad2015-10-13 15:33:53
MySQL
Nikolai Novosad, 2015-10-13 15:33:53

Should I put the result in parentheses?

Hello.
Here is the procedure:

BEGIN
set @i:=0;
SELECT @i:[email protected]+1 as number, CONCAT_WS(' ',value1, value2)
FROM job, legal, contract 
WHERE contract_id = param1 AND type_job = legal_id AND id_contract = contract_id; 
END

It is required that value1(value2) be displayed, but value2 can be null and then the parentheses are not needed.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-10-13
@nik_neman

IF(`value2` IS NULL, `value1`, CONCAT(`value1`, '(', `value2`, ')'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question