Search

Search

am 16.10.2009 02:58:15 von Emiliano Boragina

Hello
I=92m using this code to a search:

$sql =3D "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 =3D
cupones.empresa OR rubros.id =3D 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 =93clave=94.
I have three tables: empresas, rubros anda cupones.
The =93empresa=94 table has got ID and NOMBRE The =93rubro=94 table has =
got ID and
NOMBRE And the =93cupones=94 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


+              =A0 =
                         =A0=
                         =A0=
      =A0 _
   // Emiliano Boragina _
   // Dise=F1o & Comunicaci=F3n //////////////////
+              =A0 =
                         =A0=
                         =A0=
      =A0 _
   // emiliano.boragina@gmail.com=A0 /
   // 15 40 58 60 02 ///////////////////////////
+              =A0 =
                         =A0=
                         =A0=
      =A0 _



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Search

am 16.10.2009 05:43:14 von Jack van Zanen

--001485e9ac981dccec0476053275
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

For starters try this

FROM cupones
INNER JOIN empresas ON (empresas.id =3Dcupones.empresa)
INNER JOIN rubros ON (rubros.id =3D 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 al=
l
three tables, but the ID may not be the same meaning for the tables.


Jack



2009/10/16 Emiliano Boragina

> Hello
> I=92m using this code to a search:
>
> $sql =3D "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 =3D
> cupones.empresa OR rubros.id =3D cupones.rubro) WHERE (empresas.nombre LI=
KE
> '%$_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 =93clave=94.
> I have three tables: empresas, rubros anda cupones.
> The =93empresa=94 table has got ID and NOMBRE The =93rubro=94 table has g=
ot ID and
> NOMBRE And the =93cupones=94 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=F1o & Comunicaci=F3n //////////////////
> +
> _
> // emiliano.boragina@gmail.com /
> // 15 40 58 60 02 ///////////////////////////
> +
> _
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--=20
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

--001485e9ac981dccec0476053275--

Re: Search

am 16.10.2009 17:22:36 von Emiliano Boragina

--00c09ffb56b93df76604760ef74a
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

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 o=
r
mor tables yet..

Thanks

2009/10/16 Jack van Zanen

> For starters try this
>
> FROM cupones
> INNER JOIN empresas ON (empresas.id =3Dcupones.empresa)
> INNER JOIN rubros ON (rubros.id =3D 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
>
>> Hello
>> I=92m using this code to a search:
>>
>> $sql =3D "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 =3D
>> cupones.empresa OR rubros.id =3D cupones.rubro) WHERE (empresas.nombre L=
IKE
>> '%$_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 =93clave=94.
>> I have three tables: empresas, rubros anda cupones.
>> The =93empresa=94 table has got ID and NOMBRE The =93rubro=94 table has =
got ID and
>> NOMBRE And the =93cupones=94 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 retur=
n
>> only one time the coupon with the keyword insert to search...
>> Thanks a lot
>>
>>
>> +
>> _
>> // Emiliano Boragina _
>> // Dise=F1o & Comunicaci=F3n //////////////////
>> +
>> _
>> // emiliano.boragina@gmail.com /
>> // 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
>



--=20
+ _
Emiliano Boragina //
Dise=F1o y Comunicaci=F3n /////////////
+ _
emiliano.boragina@gmail.com ////
15 40 58 60 02 //////////////////////////
+ _

--00c09ffb56b93df76604760ef74a--