There is a request for MySql

SELECT COUNT(*) FROM software WHERE idPC='35' AND name='Seagull's Music' GROUP BY name; 

But he swears because of Seagull's Music single quotes. How to handle this if Seagull's Music substituted programmatically.

  • It is unlikely that it happens in the console. And from the client it is better to use parameters (parameters binding). - Akina

2 answers 2

Use double apostrophes:

 SELECT COUNT(*) FROM software WHERE idPC='35' AND name='Seagull''s Music' GROUP BY name 

An example on sqlfiddle .

    Escape quotes with a backslash:

     SELECT COUNT(*) FROM software WHERE idPC=\'35\' AND name=\'Seagull\'s Music\' GROUP BY name;