Jump to content

mysql JOIN syntax


ballhogjoni

Recommended Posts

I am trying to JOIN two tables together using the common column "Username". My code is ECHOing all of rows of column "title". I want to just ECHO the column "title" rows that are specific to the "Username".

 

example: I have a user named "ballhogjoni". This username is stored in a table named 'users' and in a table named 'products' under the column "Username". There is a "Username" column in each table.

 

How do I get my code to echo the column I want?

 

This is my code so far

<?php
		$query = "SELECT title FROM users, products WHERE users.Username = products.Username"; 
		$result = mysql_query($query) or die(mysql_error());
			while($row = mysql_fetch_array($result)){
				echo $row['title'];
				echo "<br />";
			}
		?>

Link to comment
https://forums.phpfreaks.com/topic/62048-mysql-join-syntax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.