freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Duncan Berriman" <duncan AT dcl.co.uk>
- To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] SQL nested querys
- Date: Tue, 22 May 2007 17:03:50 +0100
To answer you question directly yes this should be possible but why not
simply use a join?
Select d.descripcion from detalle d, aceros a where d.idkey = a.idkey
Always use a join (that's the point of SQL) where you can, it's a lot faster
as the data set is built on the server and done in one query. If your aceros
table holds a 1000 rows your solution will cause 1001 sql queries to be
parsed and run over odbs which will take a lot longer.
I guess you should also have a primary key on a.idkey and a key of some sort
on d.description although the above query will cause a full table scan
anyway as there is no where clause on aceros that limits the data returned.
If you need to limit the data returned in some way then simply add it to the
where clause.
Duncan
> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of
> Ricardo Quintal
> Sent: 22 May 2007 15:46
> To: freetds AT lists.ibiblio.org
> Subject: [freetds] SQL nested querys
>
>
> Hi !!! I'm more or less new using freetds and I have a
> question about it.
>
> How can I make nested querys if I have a principal query
> and a data result from it is necesary to pass to another
> query inside of a cycle.
>
> result = execsql("Select IdKey from Aceros");
>
> while (result == 0)
> {
> result = execsql("select descripcion from detalle where
> idkey = %d",idkey);
> }
>
> Is this possible ??
>
> Thanks in advance
>
> Ricardo
>
>
> ---------------------------------
>
> Llama gratis a cualquier PC del mundo.
> Con una excelente calidad de sonido.
> Yahoo! Messenger
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
-
[freetds] SQL nested querys,
Ricardo Quintal, 05/22/2007
-
Re: [freetds] SQL nested querys,
Duncan Berriman, 05/22/2007
- Re: [freetds] SQL nested querys, Ricardo Quintal, 05/22/2007
- <Possible follow-up(s)>
-
Re: [freetds] SQL nested querys,
Igor Korot, 05/22/2007
-
Re: [freetds] SQL nested querys,
Thomas, Christopher (LLU), 05/22/2007
- Re: [freetds] SQL nested querys, Duncan Berriman, 05/23/2007
-
Re: [freetds] SQL nested querys,
Thomas, Christopher (LLU), 05/22/2007
-
Re: [freetds] SQL nested querys,
Duncan Berriman, 05/22/2007
Archive powered by MHonArc 2.6.24.