Re: Search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello jack...

Is like you say... the ID in each table is not the same.
cupones.empresas is an INT field with the empresas.id number, the same with
rubros... for that reason I do that... I will try your solution, for me is
not e good solution that code I type too, but dont know how work with two or
mor tables yet..

Thanks

2009/10/16 Jack van Zanen <jack@xxxxxxxxxxxx>

> For starters try this
>
> FROM cupones
> INNER JOIN empresas ON (empresas.id =cupones.empresa)
> INNER JOIN rubros ON (rubros.id = cupones.rubro)
>
> I am not sure about the join criteria you have given us, they look a bit
> suss to me. What is the field/are the fields that join the tables?
>
> I would imagine the joining should be on the ID field that is present in
> all three tables, but the ID may not be the same meaning for the tables.
>
>
> Jack
>
>
>
> 2009/10/16 Emiliano Boragina <emiliano.boragina@xxxxxxxxx>
>
>>  Hello
>> I’m using this code to a search:
>>
>> $sql = "SELECT empresas.id, empresas.nombre, rubros.id, rubros.nombre,
>> cupones.empresa, cupones.rubro, cupones.titulo, cupones.descripcion FROM
>> cupones INNER JOIN empresas INNER JOIN rubros ON (empresas.id =
>> cupones.empresa OR rubros.id = cupones.rubro) WHERE (empresas.nombre LIKE
>> '%$_GET[busqueda]%' OR rubros.nombre LIKE '%$_GET[busqueda]%' OR
>> cupones.titulo LIKE '%$_GET[busqueda]%' OR cupones.descripcion LIKE
>> '%$_GET[busqueda]%')";
>>
>> I have a input text with name “clave”.
>> I have three tables: empresas, rubros anda cupones.
>> The “empresa” table has got ID and NOMBRE The “rubro” table has got ID and
>> NOMBRE And the “cupones” table has got ID (from the coupon), EMPRESA
>> (int),
>> RUBRO (int) , TITULO, DESCRIPCION
>>
>> The client has got 100 coupons (CUPONES table) in the data base.
>> He wants to search in any of these fields, but with tath code the search
>> return 200 or 1000 results.
>>
>> If the total of coupons are 100, what should I do to the searching return
>> only one time the coupon with the keyword insert to search...
>> Thanks a lot
>>
>>
>> +
>> _
>>    // Emiliano Boragina _
>>    // Diseño & Comunicación //////////////////
>> +
>> _
>>    // emiliano.boragina@xxxxxxxxx  /
>>    // 15 40 58 60 02 ///////////////////////////
>> +
>> _
>>
>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Jack van Zanen
>
> -------------------------
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient. If you are not the intended recipient,
> please be aware that any disclosure, copying, distribution or use of this
> e-mail or any attachment is prohibited. If you have received this e-mail in
> error, please contact the sender and delete all copies.
> Thank you for your cooperation
>



-- 
+                                                    _
  Emiliano Boragina //
  Diseño y Comunicación /////////////
+                                                    _
  emiliano.boragina@xxxxxxxxx ////
  15 40 58 60 02 //////////////////////////
+                                                    _

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux