0
I have a table of Duplicates that has the month reference as string,(ex: 01/2012, 05/2016 and etc)
And I need to perform a query between a date range, if the field was Datetime I know it would be enough to use >= and <= but being a string with month and year, how can I pass a parameter with a list containing the dates I want
select * from(select ID,Duplicata,IF(Modelo ='C','Corretor',if(Modelo = 'S','Supervisor','')) as 'Tipo',(select corr_nome from corretores where corr_id = comissionado) as 'Comissionado', Valor from comissao)A1
where (select dup_mes from duplicatas dup_mes= /*<LISTA DE VALORES QUE QUERO PESQUISAR>*/
P.S. The list will contain the values of the date range(01/2017, 02/2017, 03/2017)
Philip, I think we missed a "Where" there, no?
– user28595
I only took the subselect part to exemplify the use of the
IN
, I didn’t take all theSELECT
. But it would be something like this:select * from(select ID,Duplicata,IF(Modelo ='C','Corretor',if(Modelo = 'S','Supervisor','')) as 'Tipo',(select corr_nome from corretores where corr_id = comissionado) as 'Comissionado', Valor from comissao)A1
 where (select dup_mes from duplicatas dup_mes IN ('01/2017', '02/2017', '03/2017'))
– Filipe Martins
@Filipemartins had put the end as an example because he didn’t know if another command would replace select, but in this case it only worked by putting Where before Dup_mes, it would be interesting to update the answer to anyone who searches for it to have the answer 100% ok! thanks for saving me haha
– Leo Longhi