Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querying two tables

Status
Not open for further replies.

riffy

Programmer
Mar 29, 2001
106
0
0
US
I have a question in getting values from two tables and checking to see whether they are equal.

The first table is called "A".
The second table is called "B".

Users get assigned a group_id number associated with their user_id in table "B". If they have been granted access to a particular forum, then that group_id is inserted into "A".

The administrator wants to see who has been given access and who hasn't.
I have been trying this for the past 3 hours and I can't get it.

in PHP it would be:
Code:
$sql = "SELECT group_id FROM B LEFT JOIN A ON B.group_id=A.group_ID";
$result = mysql_query($result);

if ($row = mysql_fetch_array($result)) {
  print "yes";
} else {
  print "no";
}

is there another way of querying the two tables?? what am i doing wrong?

arif

 
Have you taken your query and pasted it into your preferred MySQL management software? Does it return what you expect?


Why does your PHP script do nothing more than return a "yes" if it can fetch a row from the return of the query? Shouldn't you actually do something more with the values you're placing into $row?

Aren't you interested in more than one row of the return?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top