I'm implementing a search function with multiple fields and using @Query. But when I send all params, I want skip from Like fields that I don't send from frontend. For example:
select dp.* from cat_productos p
inner join cat_datos_producto dp on dp.prd_id = p.prd_id
inner join cat_categorias c on dp.cat_id = c.cat_id
inner join cat_empresas e on dp.emp_id = e.emp_id
where p.prd_sku LIKE '%' or
UPPER(p.prd_descripcion) like '%%' and UPPER(p.prd_departamento) like '%%' and
UPPER(p.prd_marca) like '%%' and p.prd_codigo_int LIKE '%' and
c.cat_id = 2 and e.emp_id = 1;
This query return always all data because only c.cat_id and e.emp_id have values and the others have an empty string.
But if, from frontend I just send cat_id and emp_id, I want to skip the fields for example prd_sku, and prd_descripcion. Also the other fields that have empty string like this:
select dp.* from cat_productos p
inner join cat_datos_producto dp on dp.prd_id = p.prd_id
inner join cat_categorias c on dp.cat_id = c.cat_id
inner join cat_empresas e on dp.emp_id = e.emp_id
where c.cat_id = 2 and e.emp_id = 1;