Jump to content

LEFT JOIN problem


kumpel
 Share

Recommended Posts

Hi I have the following script which seems to come up with an error all the time, I am doing something wrong I just dont know what, cxan someone help? <?phpmysql_connect ("localhost", "xxxx","xxxxx") or die (mysql_error());mysql_select_db ("xxxxxxxxx"); $sql_statement = "SELECT items.quantity". "FROM items LEFT JOIN orders". "ON items.CHECKOUT_ID=orders.CHECKOUT_ID". "ORDER BY orders.ORDER_ID"; $result = mysql_query($sql_statement) or die(mysql_error());while($row = mysql_fetch_array($result)) { echo $row['quantity']. " ". $row['size']; echo "<br />";} ?>

Link to comment
Share on other sites

showing the error is always helpful to us to help you and locate the problem specificaly."SELECT items.quantity"."FROM items LEFT JOIN orders"when you concatenate it makes string like this"SELECT items.quantityFROM items LEFT JOIN orders"use spaces in between and you dont need to concatenate those.

  • Like 1
Link to comment
Share on other sites

Sorry, here is the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN ordersON items.CHECKOUT_ID=orders.CHECKOUT_IDORDER BY orders.ORDER_ID' at line 1

Link to comment
Share on other sites

$sql_statement = "SELECT items.quantityFROM items LEFT JOIN ordersON items.CHECKOUT_ID=orders.CHECKOUT_IDORDER BY orders.ORDER_ID";

try this. it should work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...