Jump to content

Recommended Posts

I'm running mySQL ver 4.1.21 with PHP and Dreamweaver

 

I have three tables

orders - customers – manufacturers

 

Two variables

$confirmation_id - $customer_id

 

Need record set that contains

orders.order_date

orders.received_date

orders.updated_date

orders.received_by

orders.destroyed_by

orders.model_number

orders.serial_number

orders.capacity

orders.confirmation_id

customers.contact_name

customers.contact_phone

manufacturers.manufacture_name

 

 

I get this error when I run my query:

 

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 'JOIN manufacturers on orders.manufacturer_id=manufacturers.manufacturer_id WHERE' at line 3

 

Here my query:

 

SELECT orders.order_date, orders.received_date, orders.updated_date,orders.received_by,orders.destroyed_by,orders.model_number, orders.serial_number, orders.capacity, orders.confirmation_id, customers.contact_name, customers.contact_phone, manufacturers.manufacture_name FROM orders

LEFT JOIN customers on orders.customer_id = $customer_id

LEFT JOIN manufacturers on orders.manufacturer_id=manufacturers.manufacturer_id WHERE orders.confirmation_id =$confirmation_id",

 

Any idea what I'm doing wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/49351-solved-query-using-left-join/
Share on other sites

actually, I would move the $customer_id clause to the where...like

 

 

SELECT orders.order_date, orders.received_date, orders.updated_date,orders.received_by,orders.destroyed_by,orders.model_number, orders.serial_number, orders.capacity, orders.confirmation_id, customers.contact_name, customers.contact_phone, manufacturers.manufacture_name FROM orders
LEFT JOIN customers on orders.customer_id = customers.customer_id
LEFT JOIN manufacturers on orders.manufacturer_id=manufacturers.manufacturer_id 
WHERE orders.confirmation_id ='$confirmation_id' AND orders.customer_id = '$customer_id'

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.