I would like to know if a way I can optimize this sql (mysql) code I did, the search is very slow, taking too long to bring the selected fields, I've already done some testing but it's still the same. >
SELECT
rc470.cod_item as 'Código do Produto',
r0200.descr_item as 'Descrição',
GROUP_CONCAT(DISTINCT rc470.cst_icms) as 'CSTs'
FROM rc470
INNER JOIN r0200
ON rc470.cod_item = r0200.cod_item
GROUP BY rc470.cod_item
HAVING COUNT(DISTINCT cst_icms) >= 2;
This code does a search on two tables, grouping the results of rc470.cod_item and rc470.cst_icms, where it will only display the cod_item with more than one different cts_icms and the inner join to search for the product description in table r0200 which has the same code with the rc470 table.
I hope I have been clear
Thank you