Jump to content

Inner Join


ckrudelux
 Share

Recommended Posts

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 'ON table1.g_id=table2.g_id' at line 1

<?php	$select = mysql_query("SELECT table1.g_id, table2.g_id FROM table1 INNER JOIN table2 WHERE table1.u_id='1' and table2.m_id='1' ON table1.g_id=table2.g_id");	$count = mysql_num_rows($select);	echo $count;	echo mysql_error();?>

I haven't used inner join before so I'm not sure if I wrote the right statement here so I have no clue whats wrong.I have two tables I want to compare but only where u_id is equal to 1 in table1 and where m_id is equal to 1 in table2.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...