Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql help
Message
From
11/06/2008 11:29:04
 
 
To
11/06/2008 11:03:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01323101
Message ID:
01323119
Views:
11
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
Previous
Reply
Map
View

Click here to load this message in the networking platform