GROUP BY from_user_id;
In your original query I think you meant to select from, not to, since to will
be 1;
- Original Message -
From: "John Kopanas" <[EMAIL PROTECTED]>
To:
Sent: Sunday, March 11, 2007 12:59 PM
Subject: Re: Finding a Solution To A Distinct Problem of Mi
be 1;
- Original Message -
From: "John Kopanas" <[EMAIL PROTECTED]>
To:
Sent: Sunday, March 11, 2007 12:59 PM
Subject: Re: Finding a Solution To A Distinct Problem of Mine
I think I got it:
SELECT * FROM (SELECT * FROM messages ORDER BY created_at DESC) as
messages
Ok, did not work... hmmm... any other suggestions?
On 3/11/07, John Kopanas <[EMAIL PROTECTED]> wrote:
I think I got it:
SELECT * FROM (SELECT * FROM messages ORDER BY created_at DESC) as
messages WHERE to_user_id = 1 GROUP BY from_user_id;
Is this the best way about it... or are their better
I think I got it:
SELECT * FROM (SELECT * FROM messages ORDER BY created_at DESC) as
messages WHERE to_user_id = 1 GROUP BY from_user_id;
Is this the best way about it... or are their better ways you suggest?
On 3/11/07, John Kopanas <[EMAIL PROTECTED]> wrote:
I have the following table:
mess
I have the following table:
messages:
if:
from_user_id:
to_user_id:
body:
created_at:
updated_at:
I have to return all the rows that have a distinct from_user_id based
on a to_user_id. Not only that but I want to return the rows with the
newest created_at.
I thought this would work:
SELE
Tanner Postert wrote:
I actually solved my own problem...
SELECT t1.item_id, t1.dt, t1.text ,t3.*
FROM table AS t1, table3 as t3
LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AND t1.dt < t2.dt
WHERE t2.item_id IS NULL;
becomes
SELECT t1.item_id, t1.dt, t1.text
FROM (table AS t1, table3 as t
I actually solved my own problem...
SELECT t1.item_id, t1.dt, t1.text ,t3.*
FROM table AS t1, table3 as t3
LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AND t1.dt < t2.dt
WHERE t2.item_id IS NULL;
becomes
SELECT t1.item_id, t1.dt, t1.text
FROM (table AS t1, table3 as t3)
LEFT JOIN table AS t
the below query worked great in mysql 3.23, but we just moved to 5.0 and it
broke, i can see that the join rules changed in 5.0, but i can't get the
right syntax to make this query work. any help would be appreciated.
On 6/28/06, Peter Brawley <[EMAIL PROTECTED]> wrote:
Tanner
>I am trying t
Tanner
>I am trying to group my results by the last activity on each row,
my query
>looks like this
>select text, dt, item_id from table
>where
>group by item_id
>order by dt DESC
SELECT t1.item_id, t1.dt, t1.text
FROM table AS t1
LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AN
Use the MAX() function, like so:
select text, MAX(dt) as dt, item_id from table
where
group by item_id
order by dt DESC
Dan
On 6/28/06, Tanner Postert <[EMAIL PROTECTED]> wrote:
The situation is somewhat hard to describe, so please bare with me:
I am trying to group my results by the la
The situation is somewhat hard to describe, so please bare with me:
I am trying to group my results by the last activity on each row, my query
looks like this
select text, dt, item_id from table
where
group by item_id
order by dt DESC
here is an example record set.
text1,2006-06-28 10:00
t: Tuesday, February 08, 2005 7:19 PM
To: mysql@lists.mysql.com
Subject: SELECT DISTINCT Problem
I have a large database that I am trying to run a SELECT DISTINCT
across.
SELECT DISTINCT Date FROM tb_spots WHERE aired_station = '??'
However the results I am getting from this query do
I'm not aware of any problems with DISTINCT, though it often seems that how
people expect it to work differs from how it actually works.
It would help if you could provide more details. For example, what do you
mean by "large gaps"? Do you mean there are rows which match the WHERE
condition w
I have a large database that I am trying to run a SELECT DISTINCT
across.
SELECT DISTINCT Date FROM tb_spots WHERE aired_station = '??'
However the results I am getting from this query do not match up with
the data on the database, instead there are large gaps.
Is there any know problem with SE
Hello,
i've the db of CD Titles which among others contains tables:
Titles
Songs
SongAuthors
SongIntereprets
Persons
I need to perform queries which outputs a set of Titles matching the criteria which
restrict either or all of the tables. If I make a join of the tables with restrictions
on ea
Already done my friend - works like a dream.
best, Graham
-Original Message-
From: Jeremy Zawodny <[EMAIL PROTECTED]>
To: Graham Nichols <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: 29 July 2001 10:39
Subject: Re: DISTINCT problem
>On Th
On Thu, Jul 26, 2001 at 09:31:29PM +0100, Graham Nichols wrote:
>
> Distinct can only be used with count
>
> count(distinct field_name) --- OK for 3.23 NOT for 3.22
>
> from MYSQL version 3.23. I have only version 3.22. How can I get
> around this please?
Upgrade? :-)
--
Jeremy D. Zawo
Hi,
Distinct can only be used with count
count(distinct field_name) --- OK for 3.23 NOT for 3.22
from MYSQL version 3.23. I have only version 3.22. How can I get around
this please?
kind regards,
Graham Nichols
-
Be
On 18-Mar-01 Tom Beidler wrote:
> I'm trying to populate a pulldown menu with distinct values from a found set
> using the following query.
>
> SELECT DISTINCT name FROM request
> WHERE id <= '5' OR demo_id = '$demo_id'
> ORDER BY name
>
> Apparently I am doing something wrong. If I hav
I'm trying to populate a pulldown menu with distinct values from a found set
using the following query.
SELECT DISTINCT name FROM request
WHERE id <= '5' OR demo_id = '$demo_id'
ORDER BY name
Apparently I am doing something wrong. If I have a record with the same name
that meets the WHER
I don't have internet access at home, also the mysqlbug script could not send
the mail automaticaly, but have edited the output and included it as
attachement.
and once again:
there is a problem with 'select distinct' in some case (distinct+join+order by)
the problem is to see in attached file
21 matches
Mail list logo