Is there any difference between the following two codes? Does putting '' around the column names have any effect in SQL run from a PHP program ?
Code 1: SELECT f.id FROM sample_table f;
Code 2: SELECT f.'id' FROM sample_table f;
Is there any difference between the following two codes? Does putting '' around the column names have any effect in SQL run from a PHP program ?
Code 1: SELECT f.id FROM sample_table f;
Code 2: SELECT f.'id' FROM sample_table f;
Yes, it will break the SQL
Table and of Column names should not be quoted, only literal strings should be quoted.
If you need to wrap table or column names, then you use backticks (`) (at least for MySQL), not quotes (')
From the question I will imply that you are referring to SQL dialect where the single quote is a identifier escape character.
If that is the case, difference between them is that it is possible (but not recommended) to use reserved keywords as identifier names. For example:
will result in error: SELECT f.where FROM sample_table f;
works as expected: SELECT f.'where' FROM sample_table f;