Select accoss 2 tables

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. ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-11-2004
ShowOffs.ca
 
Posts: n/a
Default Select accoss 2 tables

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



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:38 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0