Same query to get data from more that one tables
I have in the same database different tables:
And so on...
How can I in the same query in order to list me all the countries if meet the conditions sales=’1’ and active=’1’.
$connect = mysql_connect ("server", "username", "pass") or die ("bla...bla...");
mysql_select_db($database, $connect) or die ("bla...bla...");
$sql="select * from inter_main_".country." where sales = '1' and active = '1' group by country asc";
$result = mysql_db_query("database", $sql);
$arr=$regist ['country']; ?>
<td><? echo substr($arr, 0,24); ?>.</a></b></td>
<? } ?>
This only gives me the list of countries in the country column that are in the same table: inter_main
Last edited by JoseSilva; 03-06-2010 at 03:31 PM.
The right question to ask is, "how do I normalize my database tables", and the answer is here. If you are forced to stick with your current structure you could UNION results from all three tables but you aren't really gaining anything much there. The cause of the issue is your database structure so I would suggest fixing that rather than trying to work around it.
The first rule of Tautology Club is the first rule of Tautology Club.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)