MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:March 12 1999 12:29am
Subject:mysql: Need help building query - reposted
View as plain text  
>>>>> "Matthias" == Matthias Pigulla <mp@stripped> writes:

Matthias> Hi Monty & folks,
Matthias> some weeks ago I posted the following (snipped). Sorry for bothering you
Matthias> again.

Matthias> Matthias Pigulla wrote:
>> I have tables for the threads (id and topic), postings (id, key
>> referencing a thread, key referencing its author and the text) and the
>> users (id, properties i.e. nickname).
>> Now, I want to generate a list of all discussion threads in a certain
>> board. I want it to contain *) the date of the last posting *) the user
>> who initiated the thread with the first posting.

Matthias> The problem was how to select a certain row of a set before the rows are
Matthias> GROUPed together. { All rows have the same value in one column, but
Matthias> different values in another. I want to get the row - and only one row
Matthias> for each value in the first column - with the smallest value in the
Matthias> second column. }

The following entry from the Manual should help you:

In some specific cases, you can use MIN() and MAX()
get a specific column even if it isn't unique. The following gives the value
of 'column' from the row with the smallest 'sort' value:


Matthias> I was pointed to the HAVING clause, but can't get it to work. Neither
Matthias> can I find a good explanation for it in the docs. Can you explain it to
Matthias> me please?

HAVING can't help you;  Its exactly like a WHERE, but on the result set.

Matthias> What about SELECT DISTINCT? Does it work in the .19 release?

It works in all MySQL relesaes, but will not probably not solve your problem.

mysql: Need help building query - repostedMatthias Pigulla11 Mar
  • mysql: Need help building query - repostedMichael Widenius12 Mar