If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > 2 SELECTS in 1 Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-04, 15:19
watchachi watchachi is offline
Registered User
 
Join Date: Jan 2004
Posts: 17
2 SELECTS in 1 Query

Hi,

i'm trying to do a query that shows a value of one day if that value is different from the same value in another day. All values at the same table. Like this:

the table is like this

date | value

i tried something like this and it gives me a syntax error.

SELECT * FROM table WHERE date = '2004-06-02' and value = (SELECT value FROM table WHERE date = '2004-06-01')
Reply With Quote
  #2 (permalink)  
Old 06-07-04, 17:06
Strikerz95 Strikerz95 is offline
Registered User
 
Join Date: May 2004
Posts: 28
Try putting the "from table" section at the end of the statement (as long as everything is being pulled from one table. Like this:

SELECT * WHERE date = '2004-06-02' and value = (SELECT value WHERE date = '2004-06-01') FROM table;
Reply With Quote
  #3 (permalink)  
Old 06-08-04, 08:27
watchachi watchachi is offline
Registered User
 
Join Date: Jan 2004
Posts: 17
It still give me syntax errors. i tried to subquery with other tables and it
doesn't work either.

I dont understand, the version of the mysql here is 4.1.1 and it is suposed to support this kind of query.
Reply With Quote
  #4 (permalink)  
Old 06-08-04, 08:39
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
This is purely a guess, so you'll have to check it over carefully, but:
Code:
SELECT date, value
   FROM table AS a
   WHERE  '2004-06-02' = date
      AND value <> (SELECT value
         FROM table AS b
         WHERE '2004-06-01' = date);
This is a pure "shot in the dark", but it is my best guess based on your original posting.

-PatP
Reply With Quote
  #5 (permalink)  
Old 06-08-04, 16:01
watchachi watchachi is offline
Registered User
 
Join Date: Jan 2004
Posts: 17
I just saw that my mysql version is 4.0 and not 4.1 as i tought. I think the subqueries
are fine.. my DB that is outdate. And i tried to update to the 4.1 but i got errors.
thanks for the answers...
Reply With Quote
  #6 (permalink)  
Old 06-08-04, 16:05
Leaden Leaden is offline
Registered User
 
Join Date: Dec 2003
Location: Houston, TX
Posts: 21
install the current stable version to a different directory

copy over all the info in the /mysql/data directory

check to see if you need to chown mysql:mysql .. the new directory

delete the old directory

rename the new directory to the old one

.. poof you have upgraded ..

that's how I would do it. I am running 4.3.4 atm.
__________________
I do not fear computers. I fear the lack of them.
-Isaac Asimov (1920 - 1992)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On