This is a discussion on Select accoss 2 tables within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi everyone, A bit stuck....and I will try to explain well. I have 2 tables in a MySQL database. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi everyone,
A bit stuck....and I will try to explain well. I have 2 tables in a MySQL database. In PHP I am trying to find the first occurance of a row from table1 that does not have 2 things in common with table2. Table1 Structure: id part qty Table2 Strructure id partid comments user Now..the ID in each table is i's own unique in it's table.... What I need to do, is find the first occurance in table1 where the id from table1 is NOT in the partid of table2, AND the user in table2 is NOT the current logged in user. THe result I want is the id from table1. So.....here is what I tried. $username = 'bob'; $query = "SELECT id FROM table1 WHERE table1.id NOT LIKE table2.partid AND table2.user NOT LIKE '$username' LIMIT 1"; $result = mysql_query($query); $photo = mysql_result($result,0); My PHP gives this error: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in FILENAMEREMOVED on line 46 Any help would be appreciated. THanks |