Ok, Thanks for all Roger. -----Mensaje original----- De: Roger Baklund [mailto:[EMAIL PROTECTED] Enviado el: viernes, 22 de abril de 2005 4:06 Para: Dto. Sistemas de Unitel CC: mysql@lists.mysql.com Asunto: Re: Query Problem
Dto. Sistemas de Unitel wrote: > You don't understand me, I refer that if in a table I use productos.prod_id > and in other table indexes.id if I can use this two fields like the same > index, because when I named the two equal, the index start to work fine. There should be no problem with joining two tables based on columns with different names. "productos.prod_id=indexes.id" should work. Both columns could be indexed, (in two separate indexes, of course, as they are in two separate tables), but only one index will be used, depending on the join order. It does not matter if you write "productos.prod_id=indexes.id" or "indexes.id=productos.prod_id", and it does not matter if you write "FROM productos,indexes" or "FROM indexes,productos" (unless STRAIGHT_JOIN is used). In this case (se earlier posts in this thread) the table named indexes should be read first, then productos. That means an index on productos.prod_id will be used, if available. The name of the column in the productos table or the name of the related column in the indexes table does not matter. The "=" character in the ON clause or in the WHERE clause dictates which columns are related, not the name of the columns. I don't know why your index did not work at first. -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]