Re: Finding a Solution To A Distinct Problem of Mine

2007-03-13 Thread John Kopanas
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

Re: Finding a Solution To A Distinct Problem of Mine

2007-03-12 Thread Brent Baisley
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

Re: Finding a Solution To A Distinct Problem of Mine

2007-03-11 Thread John Kopanas
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

Re: Finding a Solution To A Distinct Problem of Mine

2007-03-11 Thread John Kopanas
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

Finding a Solution To A Distinct Problem of Mine

2007-03-11 Thread John Kopanas
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

Re: Distinct problem

2006-07-18 Thread Gerald L. Clark
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

Re: Distinct problem

2006-07-18 Thread Tanner Postert
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

Re: Distinct problem

2006-07-18 Thread Tanner Postert
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

Re: Distinct problem

2006-06-28 Thread Peter Brawley
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

Re: Distinct problem

2006-06-28 Thread Dan Buettner
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

Distinct problem

2006-06-28 Thread Tanner Postert
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

RE: SELECT DISTINCT Problem

2005-02-09 Thread Boyd E. Hemphill
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

Re: SELECT DISTINCT Problem

2005-02-08 Thread Michael Stassen
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

SELECT DISTINCT Problem

2005-02-08 Thread James Purser
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

DISTINCT problem

2001-12-14 Thread Miroslav Renda
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

Re: DISTINCT problem

2001-07-29 Thread Graham Nichols
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

Re: DISTINCT problem

2001-07-29 Thread Jeremy Zawodny
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

DISTINCT problem

2001-07-27 Thread Graham Nichols
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

RE: Newbie DISTINCT problem

2001-03-17 Thread Don Read
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

Newbie DISTINCT problem

2001-03-17 Thread Tom Beidler
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

distinct problem with join and order by

2001-02-13 Thread Pavel Riha
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