ckrudelux Posted January 26, 2010 Share Posted January 26, 2010 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 More sharing options...
Synook Posted January 26, 2010 Share Posted January 26, 2010 http://w3schools.com/sql/sql_join_inner.aspI think the ON clause has to come right after the JOIN clause. Link to comment Share on other sites More sharing options...
ckrudelux Posted January 26, 2010 Author Share Posted January 26, 2010 http://w3schools.com/sql/sql_join_inner.aspI think the ON clause has to come right after the JOIN clause.Looks like you where right thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted January 26, 2010 Share Posted January 26, 2010 Specifically, it needs to be before WHERE. A WHERE clause goes after the joins. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.