Page 1 of 1

MySQL query, with embedded further query: how?

Posted: Fri Feb 05, 2010 9:36 am
by simonmlewis

Code: Select all

$result = mysql_query ("SELECT * FROM products WHERE userid = '$cookieid' AND method = '123' AND status != 'sold' OR accepted IS NULL AND deleted is NULL");
I need to view all products for the logged in user, only where the method is "123" but within that, only where status is NOT sold, OR.... where accepted IS NULL.... as well as not being deleted.

If this makes sense, please help, as I am getting
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
which I assume is from my $result query.

Re: MySQL query, with embedded further query: how?

Posted: Fri Feb 05, 2010 9:39 am
by aravona
Post where ur using mysql_num_rows() ?

Re: MySQL query, with embedded further query: how?

Posted: Fri Feb 05, 2010 9:43 am
by simonmlewis
It's ok - I found it.

Code: Select all

$result = mysql_query ("SELECT * FROM products WHERE userid = '$cookieid' AND method = '123' AND (status != 'sold' OR accepted IS NULL) AND deleted is NULL");
This works perfect.

Thanks anyway. Not sure what you meant.

Re: MySQL query, with embedded further query: how?

Posted: Fri Feb 05, 2010 9:45 am
by aravona
Ahh ok - its just you posted an error for one thing and didn't show the line with the mysql_num_rows in lol my habit of liking to view everything I guess ^_^