0

I am studying SQL and I have been trying to see what is wrong with this and can't seem to figure it out.

SELECT * 
FROM l_suppliers
WHERE suppliers_name = 'frank reed's vegetables';
1
  • Rachel: Welcome to Stack Overflow! It looks like you received some good answers pretty quickly to this, but for future questions you should also post the error messages that you are receiving. It wasn't necessary here for some people to see your problem, but it will be more helpful as you learn more and get into more complex areas. Commented Sep 26, 2012 at 22:08

7 Answers 7

6

You've got a quote mark ' in the middle of your quotation. Try this:

SELECT * FROM l_suppliers WHERE suppliers_name = 'frank reed''s vegetables';
Sign up to request clarification or add additional context in comments.

Comments

6

you need to escape the string delimiter ' with '' or \'

SELECT * FROM l_suppliers 
WHERE suppliers_name = 'frank reed''s vegetables';

Otherwise the SQL engine would think that the string ends after reed and does not know what to do with the rest of the query.

Comments

5

The problem is with ', you have to use escape char like \ or '.

For example oracle, tsql (sybase, ms sql server):

SELECT * FROM l_suppliers WHERE suppliers_name = 'frank reed''s vegetables';

Comments

3

It looks like you have an incomplete string in the statement.

You must escape the ' with '' in order to successfully execute it.

SELECT * FROM l_suppliers WHERE suppliers_name = 'frank reed''s vegetables';

Comments

3

You have an embedded single-quote in your supplier name. That breaks the statement. Embedded single quotes should be doubled like so:

SELECT * FROM l_suppliers WHERE suppliers_name = 'frank reed''s vegetables';

Comments

1

You can try this it might give different results

 SELECT 
 * 
 FROM l_suppliers
 WHERE suppliers_name = 'frank reed''s vegetables';

or

 SELECT 
 * 
 FROM l_suppliers
 WHERE suppliers_name LIKE 'frank reed''s vegetables%';

or

 SELECT 
 * 
 FROM l_suppliers
 WHERE suppliers_name LIKE '%frank reed''s vegetables%';

Comments

0

In sql it is used the single quote for delimiting alfanumeric fields, so if you have a single quote inside your string sql thinks it ends there. You must escape it or replace it with ''.

Comments

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.