Page 1 of 1

MySQL out of date?

Posted: Wed Sep 14, 2005 6:00 am
by jurriemcflurrie
Hey I have a MySQL code wich works perfectly in my webserver, but on the webserver where it has to be run I get an error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT rem_girl_id FROM son_remember WHERE rem
The code is as follows:

Code: Select all

mysql_query("
  SELECT *
  FROM
    son_girls
  WHERE
    girl_id NOT IN
      (
        SELECT rem_girl_id
        FROM son_remember
        WHERE
          rem_ip='$remote_ip'
      )
")or die("".mysql_error());
I suspect that it has something to do with the version of MySQL wich is 3.23.57: http://www.mohawk-studios.com/info.php

Im I right, was it not yet supported in that version to do things like that (I couldn't find an answer on the internet) or am I doing something wrong?

Posted: Wed Sep 14, 2005 6:27 am
by JayBird
That version of MySQL doesn't support subselects.

subselects (subqueries or nested queries) were introduced in version 4.1 i think

Posted: Wed Sep 14, 2005 6:35 am
by sheila

Posted: Wed Sep 14, 2005 7:33 am
by jurriemcflurrie
It worked! Thanks again

Posted: Mon Oct 03, 2005 7:37 am
by jurriemcflurrie
... it didn't work :P

Problem is that I need rows where son_girls.girl_id NOT exist in son_remember.rem_girl_id. I came up with this:

Code: Select all

SELECT
  son_girls.*
FROM
  son_girls
LEFT JOIN
  son_remember ON 
  son_girls.girl_id!=son_remember.rem_girl_id
WHERE
  son_remember.rem_ip='$remote_ip'
I thought it worked, but every time that a row matches $remote_ip, it gives all rows that did not match rem_girl_id.

So I get like 2000 rows returned :S

strange that I can't find anything about this on internet, I'm sure that I'm not the only one with this prob :P

Posted: Mon Oct 03, 2005 7:40 am
by feyd
Useful posts wrote:Find all records that aren't matching: SQL SELECT JOIN HELP

Posted: Mon Oct 03, 2005 8:11 am
by jurriemcflurrie
FINALLY it works!!! :D thanks!