Skip to content
Advertisement

How to put brackets around a SQL result, via SQL query?

I have a sql query inside the jasper report and I want to put brackets around a specific generated result from it .

This is sql query,

SELECT `idMedication`,`idPatient`, `Drug` from medication

I want to put a brackets around Drug from the result, and I require to do it via the SQL code it self.

For an example, at the moment a drug is displayed like “Paracetamol” but I require it as “(Paracetamol)

Any idea on how to do this?

Advertisement

Answer

You can use the CONCAT function :

SELECT `idMedication`,`idPatient`, CONCAT('(', `Drug` ,')') AS Drug from medication 
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement