At 22:04 +0100 28/6/06, I wrote:
I have two tables: pix and sections, the relevant bits of which are:

pix (2,421 rows):
picid       varchar(7)             not null
sectionid   smallint(5) unsigned   not null
caption     text                   null
   picid and sectionid are a joint primary key
   caption is full text indexed

sections (a mere 152 rows):
sectionid   smallint(5) unsigned   not null
title       varchar(63)            not null
blurb       text                   null
   sectionid is primary key (auto increment)
   title and blurb are full text indexed

... I want to find the first instance of each picid that matches the text anywhere in caption, title or blurb, and get some other info at the same time. Oh, and for the time being it needs to be possible in MySQL 3.23.x.

Solved! (Just as well as no-one replied :-) )

Quite by chance, Tanner Postert's question about the same time had the answer for me:

At 14:27 -0700 28/6/06, Tanner Postert wrote:
select text, dt, item_id from table
where ....
group by item_id
order by dt DESC

It had never occurred to me that there was any validity in using 'group by' without a summary function of some sort, but this does of course solve my problem at a stroke. It doesn't solve Tanner's of course because he wants a /particular/ instance returned, whereas I just want any one.

So now it's all done with one tidy query, instead of a new query for each result from the first query.

Thanks, Tanner!

--
Cheers... Chris
Highway 57 Web Development -- http://highway57.co.uk/

When you've seen one shopping centre, you've seen a mall.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to