Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
jurriemcflurrie
Forum Commoner
Posts: 61 Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands
Post
by jurriemcflurrie » Wed Sep 14, 2005 6:00 am
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?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Sep 14, 2005 6:27 am
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 » Wed Sep 14, 2005 6:35 am
jurriemcflurrie
Forum Commoner
Posts: 61 Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands
Post
by jurriemcflurrie » Wed Sep 14, 2005 7:33 am
It worked! Thanks again
jurriemcflurrie
Forum Commoner
Posts: 61 Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands
Post
by jurriemcflurrie » Mon Oct 03, 2005 7:37 am
... it didn't work
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Oct 03, 2005 7:40 am
jurriemcflurrie
Forum Commoner
Posts: 61 Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands
Post
by jurriemcflurrie » Mon Oct 03, 2005 8:11 am
FINALLY it works!!!
thanks!