0

So I'm working on HW and I can't figure out why I'm getting a syntax error in my sql query.

For some reason this doesn't work. company_name is a varchar.

SELECT customer.contact_name, order.order_id, order.completed, order.cancelled 
FROM mystudentID_customers customer, mystudentID_orders order 
WHERE customer.company_name = 'Rosas Bank' 
AND order.cust_id = customer.cust_id 
;

And gives me this 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 'WHERE customer.company_name = 'Rosas Bank' AND order.cust_id = customer.cust_id' at line 3

But I can run this just fine, I don't see how they are different and one works and another doesn't.

SELECT employee.first_name, employee.state, customer.contact_name, customer.state 
FROM mystudentID_employees employee, mystudentID_empcust empcust, mystudentID_customers customer WHERE employee.emp_id = empcust.emp_id AND customer.cust_id = empcust.cust_id 
AND employee.state = customer.state 
;

This also works

Select customer.company_name 
FROM mystudentID_customers customer 
WHERE customer.company_name = 'Rosas Bank' 
;

I tried to do a smaller statement to check if I could actually do = "string" and it worked. I also googled the error and nothing similar is showing up.

Zak
  • 6,976
  • 2
  • 26
  • 48

0 Answers0