in DB i have two tables named my one and two.in table one there is a colum named by name and in table two there is colum named by address. when i run the query it show the result but the problem with this is that it show same result two times. can any one pleaze help me out.

in database table is like that
name address
ali1 hyderabad
hyder1 karachi



// Make a MySQL Connection
// Construct our join query
$query = "SELECT one.name,two.address FROM one,two";
$result = mysql_query($query) or die(mysql_error());

echo " name "."address";
echo "<br />";

while ($row=mysql_fetch_array($result)){


	echo $row['name']. " - ".$row['address'];

echo "<br />";




name address
ali1 - hyderabad
hyder1 - hyderabad
ali1 - karachi
hyder1 - karachi

6 Years
Discussion Span
Last Post by ddymacek

you should have an identifier on one and two that tie the two tables together like an id, or the name.
your query would look something like

$query="SELECT one.name,two.address FROM one,two where one.name=two.name";
// or some identifying field that ties that particular address to that particular name
$query="SELECT one.name,two.address FROM one,two where one.id=two.id";

it's a little more complex than that but you need to tie the address to the name record in some other way

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.