* Elisenda > I have a query which tries to select different fields from 5 different > tables. > > In WHERE part I have write all the conditions and relationships. > Perhaps two many.....
Joining 5 tables should not be a problem, but having indexes on the relevant columns may be essential, especially on large tables. > The main table for me is FASE. From this table I try to find all the other > information. > > I guess I'm doing something wrong but I don't know what. What is the problem? Do you get an error message, does it return unexpected results, or is it just too slow? > SELECT > > CE.CE_CENTRO, > CE.CE_DOMICILIO, > CE.CE_CP, > CE.CE_POBLACION, > CE.CE_PROV, > PP.PP_CONTACTO, > PP.PP_CARGO, > CA.CA_HORARIO, > AU.AU_A_M, > AU.AU_A_F, > FASE.PR_DATE_VISITA_1 > > FROM AU, CA, CE,FASE,PP > > WHERE > > FASE.SQL_ID_PY='P081' AND > FASE.PR_FLAG= '1' AND > CA.CA_ID_IDIOMA_A= '6' AND > AU.AU_NIVEL= '13.14' AND > AU.AU_Aula= fase.AU_PR_Aula AND > AU.AU_ID_CE = CA.CA_ID_CE AND > CE.CE_ID_CE = CA.CA_ID_CE AND > CE.CE_ID_CE = Fase.SQL_ID_CE AND > CE.CE_ID_CE = PP.PP_ID_CE AND > Fase.PR_PP_ID_Coord = PP.PP_ID_PP It's difficult to suggest changes without knowing what the problem is... :) I can however safely suggest that you use a consistent letter casing on your table names... is it FASE, Fase or fase? On some MySQL servers this will make a difference, on others it may not. (I think mysql on windows is case insensitive by default, but this may be changed at compile-time, iirc.) Please tell us what the problem is, and if it's about efficiency, post the output of "EXPLAIN SELECT <your_query>", that should get us started. :) -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]