In a table (tb_medicamentos)
of my database, postgres
one of the fields (desc_medicamentos)
contains a very long value. I would like that when making the query to specify that that field brings me a length of 50 characters. How could I do that? (I'm new to postgrest)
SELECT
public.tb_medicamentos.orden,
public.tb_medicamentos.desc_medicamentos
WHERE
public.tb_medicamentos
WHERE
public.tb_medicamentos.num_medicamentos = '2019'
You can use the substring function, with the following syntax:
In this case
for 50
it means that we will take the first 50 characters, this function accepts another parameter which isfrom X
that it allows the extract to start from said position.You can also use the postgreSQL cast on the required field