This won't quite work. I probably wasn't clear - I'm not querying to find a
random property, I'm just doing this one query to grab the image. So if I
had picked a random property first, then it would be straightforward to
return one row in the next query.
[rethink]
Actually, that's what I shall do - for some reason I thought that wouldn't
work, as I have to ensure that the property has images, but I just need to
do a join in that initial query, and then query again to get the first
image.
cheers
"Snake
Hollywood" To: <[EMAIL PROTECTED]>
<[EMAIL PROTECTED] cc:
kepit.net> Subject: RE: [ cf-dev ] SQL question
28/05/2004 15:12
Please respond
to dev
In the cfquery you can set the recordcount to 1, so only 1 record is
selected
Or you can do a
Select top1
Russ
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 28 May 2004 14:39
> To: [EMAIL PROTECTED]
> Subject: [ cf-dev ] SQL question
>
>
> Got two tables Properties and Images, in a one-to-many
> relationship: one property can have many images.
>
> I want to pick one property at random, and display the first
> image belonging to that property, but can't figure out how to
> do this. It's easy enough to just display any image at random:
>
> <cfquery name="getImages" datasource="dsn">
> SELECT Imagename
> FROM Images I, Properties P
> WHERE I.PropertiesId = P.ID
> </cfquery>
>
> <cfset random = RandRange(1,getImages.RecordCount)>
>
> <cfoutput><img src="images/#getImags.Imagename[random]#"></cfoutput>
>
> However, how to limit it to just the first image for any
> random property,
> eg:
>
> Property A Image A1, Image A2, Image A3
> Property B Image B1
> Property C Image C1, Image C2, Image C3, Image C4
>
> I want to display either A1, B1 or C1 at random.... any
> ideas? So far I'm trying combinations of grouping the output
> on the propertyID, and picking a random startrow, but not
> managing to get it doing what I want.
>
>
> --
> These lists are syncronised with the CFDeveloper forum at
> http://forum.cfdeveloper.co.uk/
> Archive:
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
>
> CFDeveloper Sponsors and contributors:-
> *Hosting and support provided by CFMXhosting.co.uk* ::
> *ActivePDF provided by activepdf.com*
> *Forums provided by fusetalk.com* :: *ProWorkFlow
> provided by proworkflow.com*
> *Tutorials provided by helmguru.com* :: *Lists
> hosted by gradwell.com*
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
>
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]