I am a beginner coder, and working on a webpage using MYSQL and three tables to join tables together and print the results in a table.
** This error is populating: **
Access to the data tables failed: Table ‘swarmera7243.accomLEFT’ doesn’t exist <
I have tried experimenting with different JOIN options. and the same error populates just “INNER” or “RIGHT” instead of the left noted above.
As well as restarting both my MySQL database and Filezilla.
I’m stuck.
Any feedback and direction is appreciated!
This is my php code:
---
<table>
<tbody>
<tr>
<th>Accomodation Name</th>
<th>View</th>
<th>Capacity</th>
<th>Lodging Type</th>
<th>Price</th>
<th>Description</th>
</tr>
<?php
// pull info from database tables
$sql="SELECT accom.name, accom.view_id, accom.capacity, accom.lodging_id, accom.price, accom.description FROM accom";
$sql .= "LEFT JOIN accom_view ON accom.view_ID=accom_view.view_id";
$sql .= "RIGHT JOIN accom_lodging ON accom.lodging_ID=accom_lodging.lodging_id";
// EXECUTE THE SQL QUERY (I know this correct, used it before and worked)
$result = mysqli_query( $con, $sql );
if ( !$result ) {
die( "Access to the data tables failed: " . mysqli_error( $con ) );
}
// FETCH THE RESULTS AND DISPLAY THEM
else {
while ( $item = mysqli_fetch_array( $result ) ) {
echo
"<tr>
<td>" . $item[ 'accomodations_name' ] . " </td>
<td>" . $item[ 'view_type' ] . " </td>
<td>" . $item[ 'capacity_id' ] . " </td>
<td>" . $item[ 'lodging_type' ] . " </td>
<td>" . $item[ 'price_id' ] . " </td>
<td>" . $item[ 'description' ] . " </td>
</td>
</tr>"; //closes the table
---
My tables are:
Table Name: accom
Columns:
name
view_id
capacity
lodging_id
price
description
Table Name: accom_view
Columns:
name
view_id
view_type
Table Name: accom_lodging
Columns:
name
lodging_id
lodging_type
I have tried experimenting with different JOIN options. and the same error populates just “INNER” or “RIGHT” instead of the left noted above.
As well as restarting both my MySQL database and Filezilla
Ashley Swarmer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1