soma56 Posted September 10, 2010 Share Posted September 10, 2010 I hope I'm on the right track. I'm new to MySQL and I'm trying to compare specific rows within two different tables. Basically, what I'm trying to accomplish can be summed up like this: If row1 in table1 contains something like row1 in table2 then return it. This is what I have so far: $query = "SELECT players_scrape.player_name, players.player_name "."FROM players_scrape, players "."where players_scrape.player_name LIKE '%players_scrape.player_name%' = players.player_name"; $result = mysql_query($query) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['player_name']. " - ". $row['player_name']; echo "<br />"; } From what I understand the "LIKE" function returns a row that is similar (not necessarily exact - http://www.webmasterworld.com/forum88/5627.htm). This if what I'm going for. I think I understand how to compare rows from different tables effectively (http://www.tizag.com/mysqlTutorial/mysqljoins.php). What I'm having an issue with is comparing a little more loosely. For example: row1 table1 smith, john row1 table2 JOHN SMITH ...so that MySQL would return results like these. Quote Link to comment https://forums.phpfreaks.com/topic/213071-joining-tables-where-this-like-that/ Share on other sites More sharing options...
fenway Posted September 10, 2010 Share Posted September 10, 2010 Your where clause is incorrect. You need to compare each separately -- table1 to table2, and then table1 = somevalue. Quote Link to comment https://forums.phpfreaks.com/topic/213071-joining-tables-where-this-like-that/#findComment-1109666 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.