Hey guys i am looking for some way to search in multiple database table without using UNION. My code is pretty simple, its something like:
$con = new PDO( DB_HOST, DB_USER, DB_PASS );
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sql1 = "SELECT * FROM evidence_vin WHERE vin = :vin LIMIT 1";
$sql2 = "SELECT * FROM national_register_sk WHERE vin = :vin LIMIT 1";
$sql = $sql1 . ' UNION ' . $sql2;
$stmt = $con->prepare( $sql ) union ( $sql2 );
$stmt->bindValue( "vin", $this->vin, PDO::PARAM_STR );
$stmt->execute();
echo "<table>";
echo "<th>Progress</th>";
echo "<th>Claim number</th>";
echo "<th>Make</th>";
echo "<th>Status</th>";
echo "<th>View</th>";
echo "<th>Action</th>";
while ($row = $stmt->fetch()){
echo "<tr>";
echo "<td>24</td>";
echo "<td>".$row['claim_number']."</td>";
echo "<td>".$row['license']."</td>";
echo "<td>".$row['country']."</td>";
echo "<td>".$row['vin']."</td>";
echo "<td><a href=\"detail.php?id=".$row["id"]."&action=detail\">detail</td>";
echo "</tr>";
}
}catch(PDOExeption $e){
echo $e->getMessage();
I have some problems with this because i will need some specific data from table one and some specific from table 2 and i am not sure which one i will need yet. So i need some way to get a line from each table where VIN is $this->vin. (vin is in both tables same)
p.s. Tables dont have same number of colums