just LIMIT 1 will do.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/


On 29/05/2009 21:53, Ryan Letulle wrote:
> add LIMIT 0,1 add the end of the query to only grab the first match
> --
> Ryan
> 
> 
> 
> On Fri, May 29, 2009 at 9:50 AM, Chad Gray <[email protected]> wrote:
> 
>> Sorry should have mentioned that
>>
>> MySQL
>>
>>
>> -----Original Message-----
>> From: Ryan Letulle [mailto:[email protected]]
>> Sent: Friday, May 29, 2009 10:48 AM
>> To: cf-talk
>> Subject: Re: query question
>>
>>
>> what db
>> --
>> Ryan
>>
>>
>>
>> On Fri, May 29, 2009 at 9:41 AM, Chad Gray <[email protected]> wrote:
>>
>>> I have two tables that are joined one to many.
>>>
>>> I would like to write a query to get the one from the first table and
>> only
>>> one from the many table.
>>>
>>> TABLE1
>>> AlbumID, AlbumTitle
>>> 1, MyPictures
>>>
>>> TABLE2
>>> PictureID, AlbumID, PictureName
>>> 1, 1, test.jpg
>>> 2, 1, test2.jpg
>>>
>>> How do I write the query to only get one record from TABLE2 when I join?
>>>
>>> SELECT *
>>> FROM TABLE1
>>> JOIN TABLE2 ON TABLE2.AlbumID = TABLE1.AlbumID
>>> WHERE TABLE1.AlbumID = 1
>>>
>>> This query returns 2 records because there are two matches in TABLE2.
>>>
>>>
>>>
>>>
>>
>>
>>
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322971
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to