MySQL out of date?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
jurriemcflurrie
Forum Commoner
Posts: 61
Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands

MySQL out of date?

Post 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?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

That version of MySQL doesn't support subselects.

subselects (subqueries or nested queries) were introduced in version 4.1 i think
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

User avatar
jurriemcflurrie
Forum Commoner
Posts: 61
Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands

Post by jurriemcflurrie »

It worked! Thanks again
User avatar
jurriemcflurrie
Forum Commoner
Posts: 61
Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Useful posts wrote:Find all records that aren't matching: SQL SELECT JOIN HELP
User avatar
jurriemcflurrie
Forum Commoner
Posts: 61
Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands

Post by jurriemcflurrie »

FINALLY it works!!! :D thanks!
Post Reply