0

I keep getting an error message:

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 'details, from product inner join supplier on product.supplier_id = supplier.sup' at line 4

Any ideas? Here is my code:

    SELECT concat(product.stock_level)AS NumberOfStock,
    product.name,product.supplier_id,supplier.supplier_name,
    concat(address.supplier,'', town.supplier,'', post_code.supplier)as address,
    concat(email.supplier,'', contact_number.supplier)as contact details,
    from product inner join supplier 
    on product.supplier_id = supplier.supplier_id

    HAVING (product.stock_level) < 5
2
  • @joestefanelli . thanks i have sorted that out but still getting an error, can you spot something i cant on line 4? Commented Apr 17, 2015 at 17:05
  • It looks like the below answer completely resolves this old problem. Would you consider accepting it, please? To do so, click the tick icon to the left of the answer, so it turns green. Commented Aug 10, 2015 at 7:46

1 Answer 1

1

Your HAVING should be a WHERE instead.

HAVING is used to test the value of an aggregate function (e.g., COUNT, SUM) and would come after a GROUP BY clause.

WHERE is used to test the value of an ordinary column.

...
WHERE (product.stock_level) < 5

EDIT: After resolving the HAVING/WHERE, I now see this as well:

The last column in the select list should not have the comma after it, and the alias contact details should either be one word (contact_details or ContactDetails) or is must be escaped with backquotes to include the space (`contact details`).

...
concat(email.supplier,'', contact_number.supplier)as `contact details`
from product inner join supplier 
...
Sign up to request clarification or add additional context in comments.

1 Comment

thanks i have sorted that out but still getting an error, can you spot something i cant on line 4?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.