Hola Carlos -
You can use a subquery á la "... Where keyField In ( Select ...".
Untested:
LOCAL lcMedico, ldDate, lcTime
lcMedico = '001'
ldDate = DATE(2008,6,2)
lcTime = '16:00'
SELECT * FROM medicos ;
WHERE codigo = ?lcMedico ;
AND ;
codigo in ( ;
SELECT medico FROM ausenciasmedico ;
WHERE data_ini <= ?ldDate ;
AND data_fim >= ?ldDate ) ;
AND ;
codigo in ( ;
SELECT medico FROM horariosmedico ;
WHERE ;
entrada_manha <= ?lcTime ;
AND ;
saida_manha >= ?lcTime ;
OR;
entrada_tarde <= ?lcTime ;
AND ;
saida_tarde >= ?lcTime )
(The code is untested because you did not provide DDL like
CREATE CURSOR medicos (codigo Char(3), nome Char(30))
INSERT INTO medicos VALUES ('001', 'dr. joao')
etc. :-)
hth
-Stefan
>Good morning
>I have 3 tables:
>
>medicos
>codigo nome
>001 dr. joao
>002 dr.eugenio
>
>ausenciasmedico
>medico data_ini data_fim
>001 01/06/2008 05/06/2008
>002 15/06/2008 15/06/2008
>001 10/06/2008 10/06/2008
>
>horariosmedico
>medico entrada_manha saida_manha entrada_tarde saida_tarde
>001 08:00 12:00 15:00 18:00
>002 09:00 11:00 18:00 22:00
>
>I have in the form 3 textbox:
>one with the medico ex:(001)
>onother with the date of the consult ex:(02/06/2008)
>and another with the time of consult ex:(10:00)
>
>I want two select:
>one to detect that the medico ex:(001) is not disponible in the day 02/06/2008
>And onother to detect that the medico ex:(002) is not disponible in the time 08:00
>
>Thanks in advance.
>
>Carlos Lima