I have four tables in my database. TABLE1 having 5 columns, TABLE2 having 7, TABLE3 having 9 and TABLE4 having 11 columns respectively.
all 4 tables have a column PID, from which i want to make a user query. i.e.
SELECT pid FROM ....
the problem i am facing, is, how to choose from all the 4 tables, if my query is not found in TABLE1 then search in TABLE2, and so on.
since all tables have different structure, the result must pass differently for output, like, if query was found in TABLE1 the output would have a table with 5 columns, or if from TABLE4 the output would show 11 columns.
for now, i can make a query for only 1 table.
title
//provide your hostname, username and dbname
$host="localhost";
$username="root";
$password="";
$db_name="mydb";
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name");
$sql = "select PID from TABLE1";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "$row[PID]";
}
?>
Search