I have a 11 tables [email1, email2, email3, ... email11]
<?php
$con = mysql_connect("localhost", "root", "");
$db = mysql_select_db("email-db", $con);
$sql = "SELECT Contact_Email FROM email1, email2, email3, email4, email5";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
?>
<tr>
<td><? echo $row['Contact_Email']; ?></td>
<td><? echo '<br>'; ?></td>
</tr>
<? } ?>
What I actually want to do it to select all emails from all tables using join on all of them. How can it be done?
i used this
Since society voted to close duplicate how to display duplicate email address
Here is an example for 4 tables you can extend it till 11 if you need. Sorry, but I did not debug this code, I guess the main obstacle was the mysql query to get correct values from database.
And you definitely should stop using mysql* functions!
UPDATE Use the same query but change the output part to:
MySQL UNION operator allows you to combine two or more result sets from multiple tables into a single result set
By default, the UNION operator eliminates duplicate rows from the result even if you don’t use DISTINCT operator explicitly.