Re: How do I do this query efficiently?

2006-11-17 Thread Manuel Vacelet
2006/11/16, Peter Brawley <[EMAIL PROTECTED]>: Michael, >SELECT t1.id, t1.version, t1.value >FROM data t1 >LEFT JOIN data t2 ON t1.id=t2.id AND t1.version < t2.version >WHERE t2.id IS NULL; >I had almost the same problem and I found this solution very smart... >even smarter than I can unde

Re: How do I do this query efficiently?

2006-11-16 Thread Peter Brawley
Michael, >SELECT t1.id, t1.version, t1.value >FROM data t1 >LEFT JOIN data t2 ON t1.id=t2.id AND t1.version < t2.version >WHERE t2.id IS NULL; >I had almost the same problem and I found this solution very smart... >even smarter than I can understand :) >Can someone explain to me why/how this quer

Re: How do I do this query efficiently?

2006-11-13 Thread Sebastiaan van Erk
Wow, neat. I didn't think you could do that without a subquery somewhere. Learned a cool new trick today. Thanks! Regards, Sebastiaan Peter Brawley wrote: Right, if you want the value column you need too, you need a different query ... SELECT t1.id, t1.version, t1.value FROM data t1 LEFT JOIN

Re: How do I do this query efficiently?

2006-11-13 Thread Rolando Edwards
Pretty slick. - Original Message - From: Peter Brawley <[EMAIL PROTECTED]> To: Sebastiaan van Erk <[EMAIL PROTECTED]> Cc: mysql@lists.mysql.com Sent: Monday, November 13, 2006 10:43:26 AM GMT-0500 US/Eastern Subject: Re: How do I do this query efficiently? Right, if you wa

Re: How do I do this query efficiently?

2006-11-13 Thread Peter Brawley
Right, if you want the value column you need too, you need a different query ... SELECT t1.id, t1.version, t1.value FROM data t1 LEFT JOIN data t2 ON t1.id=t2.id AND t1.version < t2.version WHERE t2.id IS NULL; PB Sebastiaan van Erk wrote: Hi, Thanks for your quick answer, but unfortunately

Re: How do I do this query efficiently?

2006-11-13 Thread Sebastiaan van Erk
rsion; - Original Message - From: Peter Brawley <[EMAIL PROTECTED]> To: Sebastiaan van Erk <[EMAIL PROTECTED]>, mysql@lists.mysql.com Sent: Monday, November 13, 2006 9:18:49 AM GMT-0500 US/Eastern Subject: Re: How do I do this query efficiently? >for every "id" I want exactly on

Re: How do I do this query efficiently?

2006-11-13 Thread Rolando Edwards
Try this !!! - Original Message - From: Rolando Edwards <[EMAIL PROTECTED]> To: peter brawley <[EMAIL PROTECTED]> Cc: Sebastiaan van Erk <[EMAIL PROTECTED]>, mysql@lists.mysql.com Sent: Monday, November 13, 2006 9:28:46 AM GMT-0500 US/Eastern Subject: Re: How

Re: How do I do this query efficiently?

2006-11-13 Thread Sebastiaan van Erk
Hi, Thanks for your quick answer, but unfortunately this query does not return the "value" column of the row; and that is the column I am ultimately interested in (in combination with the id). Regards, Sebastiaan Peter Brawley wrote: >for every "id" I want exactly one row, namely the row wit

Re: How do I do this query efficiently?

2006-11-13 Thread Rolando Edwards
ssage - From: Peter Brawley <[EMAIL PROTECTED]> To: Sebastiaan van Erk <[EMAIL PROTECTED]>, mysql@lists.mysql.com Sent: Monday, November 13, 2006 9:18:49 AM GMT-0500 US/Eastern Subject: Re: How do I do this query efficiently? >for every "id" I want exactly one row, namely t

Re: How do I do this query efficiently?

2006-11-13 Thread Peter Brawley
>for every "id" I want exactly one row, namely the row with the maximum value of "version". SELECT id,MAX(version) FROM data GROUP BY id; PB - Sebastiaan van Erk wrote: Hi all, I have the following simple table: CREATE TABLE data ( id int NOT NULL, version int NOT NULL, value int

How do I do this query efficiently?

2006-11-13 Thread Sebastiaan van Erk
Hi all, I have the following simple table: CREATE TABLE data ( id int NOT NULL, version int NOT NULL, value int NOT NULL, PRIMARY KEY (id, version) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; What I would like to do is to find all the values for the latest versions, that is, for every "id" I

re: How do I do this select?

2004-01-11 Thread jeremy_march
> This will give me sort of what I am looking for, but it shows the > UserKey in the first column and I want the UserID. I have tried a few > others but just got errors. > SELECT f.UserKey, UserID FriendID, Name FriendName > FROM User u, FriendList f > WHERE f.FriendKey = u.UserKey > ORDER BY f.U

How do I do this select?

2004-01-11 Thread Chris W
I have the following 2 tables. CREATE TABLE User ( UserKey INT NOT NULL AUTO_INCREMENT, UserIDCHAR(16) NOT NULL UNIQUE , Name VARCHAR(20), PRIMARY KEY (UserKey) ); CREATE TABLE FriendList( UserKey INT NOT NULL, FriendKey INT NOT NULL, PRIMARY KEY (UserKey, FriendKey)

How do I do this select?

2004-01-11 Thread Chris W
I have the following 2 tables. CREATE TABLE User ( UserKey INT NOT NULL AUTO_INCREMENT, UserIDCHAR(16) NOT NULL UNIQUE , Name VARCHAR(20), PRIMARY KEY (UserKey) ); CREATE TABLE FriendList( UserKey INT NOT NULL, FriendKey INT NOT NULL, PRIMARY KEY (UserKey, FriendKey)

RE: How Do I Do This In Version 3.23.56?

2003-12-31 Thread David Mohorn
upper/lower, or all upper, etc. I'd double check all your case to ensure everything is identical. -Original Message- From: John Boshier [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 31, 2003 12:36 PM To: [EMAIL PROTECTED] Subject: How Do I Do This In Version 3.23.56? I have

How Do I Do This In Version 3.23.56?

2003-12-31 Thread John Boshier
I have spent all day working on a PHP/MySQL system offline using MySQL version 4.0.15-nt. One particular SQL statement that works perfectly wouldn't work when I uploaded it to my web site. It seems that my ISP is using version 3.23.56, and I have written a SQL statement that will only work on 4.04

How do I do this?

2001-07-21 Thread Adrian D'Costa
display another sent of 7 >records but it just keeps displaying the same. > >+---+ >| version() | >+---+ >| 3.23.36 | >+---+ > >How do I do this. > >Adrian > - Before posting, please c

Re: how do I do this?

2001-07-17 Thread Tonu Samuel
Jeff S Wheeler wrote: > [This is an email copy of a Usenet post to "mailing.database.mysql"] > > Just insert a row with the initial value you want minus one, and then > delete it. That will make the table do what you want. > > mysql> INSERT INTO Orders VALUES (-1, "", NOW(), -1, 125478); >

Re: how do I do this?

2001-07-16 Thread Jeff S Wheeler
[This is an email copy of a Usenet post to "mailing.database.mysql"] Just insert a row with the initial value you want minus one, and then delete it. That will make the table do what you want. mysql> INSERT INTO Orders VALUES (-1, "", NOW(), -1, 125478); Query OK, 1 row affected (0.03 sec)

Re: how do I do this

2001-06-15 Thread Benjamin Pflugmann
ravel t, hotel h WHERE t.nome_hotel = h.hotelname; you have to create (or specify) indexes seperately. [...] > > What I want to do is replace the nome_hotel field with the ids of the > > hotel table for names that match the hotel.hotelname in the > > travel.nome_hotel. How

RE: how do I do this

2001-06-15 Thread Adrian D'Costa
| Angela | > | Marmari Beach | > | Summer Palace | > | Aegean Village | > +-------------+ > > What I want to do is replace the nome_hotel field with the ids of the > hotel table for names that match the hotel.hotelname in the > travel.nome_hotel. How do I do t

how do I do this

2001-06-14 Thread Adrian D'Costa
in the travel.nome_hotel. How do I do this. TIA Adrian - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL