[thelist] SQL Assistance

Morgan Kelsey morgan at morgankelsey.com
Tue Apr 1 12:04:53 CST 2003


and a double ert, just do it rusy's way, as you'll get everything you need,
and not just one field...

can you tell i'm supposed to be working on something that i don't wanna do?

or is it all these great CF tips i thought up this morning, just dying to
come out....

<tip type="ColdFusion">
when performing a to= from= loop using the cfloop tag, cf processes the
"from" attribute at each iteration.

That means, if you have an array of 50 items, MyArray,
executing:

<cfloop from="1" to="#ArrayLen(MyArray)#" index="i">
<!--- process code here --->
</cfloop>

will process the ArrayLen function everytime around the loop!

Better to put the "to" value in a variable up front:

<cfset looplen = ArrayLen(MyArray)>

then the loop:

<cfloop from="1" to="#looplen#" index="i">

</cfloop>

But that's more typing, gross! So even better is to use cfscript, where the
to value is only processed once:

<cfscript>
for(i=1; i LTE ArrayLen(MyArray); i=i+1;)
{
// process code here
}
</cfscript>

this will only execute the ArrayLen function once.

</tip>


nagrom
http://morgankelsey.com/




----- Original Message -----
From: "Morgan Kelsey" <morgan at morgankelsey.com>
To: <thelist at lists.evolt.org>
Sent: Tuesday, April 01, 2003 12:37 PM
Subject: Re: [thelist] SQL Assistance


> ert, that AS should be an =
>
> AddressContactID = (SELECT TOP 1 id FROM Address WHERE AddressContactID =
> ContactID)
>
> <tip type="ColdFusion whitespace">
> The cfsilent tag is the preferreed method for controlling whitespace, as
it
> has extremely low overhead.
>
> cfsetting has a little more overhead, but also allows output to the page
> within cfoutput blocks, and the processing of cfinclude tags.
> </tip>
>
>
> ----- Original Message -----
> From: "Morgan Kelsey" <morgan at morgankelsey.com>
> To: <thelist at lists.evolt.org>
> Sent: Tuesday, April 01, 2003 12:22 PM
> Subject: Re: [thelist] SQL Assistance
>
>
> > michelle,
> >
> > subquery to the rescue...
> >
> >
> > > I've dummed down this query greatly in order to try to find a solution
> to
> > the > problem. The real query is far more complex .. but for simplicity
> this
> > shows > the problem we are encountering.  This is from the sql query
> builder
> > in
> > > Access 2K.
> >
> > ah, well *there's* your problem, heh...query wizard...grumble grumble
> >
> > SELECT
> > Contacts.ContactID,
> > Module.ModuleContactID,
> > Module.ModuleID,
> > Module.Module,
> > Address.AddressType,
> > AddressContactID AS (SELECT TOP 1 id FROM Address WHERE AddressContactID
=
> > ContactID)
> > FROM
> > Contacts
> > INNER JOIN [Module] ON Contacts.ContactID = Module.ModuleContactID
> > WHERE (((Module.Module)="CO" Or (Module.Module)="COWEB"));
> >
> > TOP 1 may not be what you want, but you get the idea...
> >
> > did i really beat rudy to this one?
> >
> >
> > nagrom
> > http://morgankelsey.com
> >
> > --
> > * * Please support the community that supports you.  * *
> > http://evolt.org/help_support_evolt/
> >
> > For unsubscribe and other options, including the Tip Harvester
> > and archives of thelist go to: http://lists.evolt.org
> > Workers of the Web, evolt !
> >
>
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !



More information about the thelist mailing list