0

can I write:

select * from table where id = 1

or should I write:

SELECT * FROM table WHERE id = 1

or no difference?

RGS
  • 4,062
  • 4
  • 31
  • 67
  • 2
    No difference, though I prefer the all caps (which would include FROM) style personally. Even table names are not case sensitive on most configurations. – Uueerdo May 17 '18 at 23:36
  • @Uueerdo thanks! I edited to add from in caps. – RGS May 17 '18 at 23:37
  • 1
    Go even further and use your ticks: `SELECT * FROM \`table\` WHERE \`id\` = 1` – Kai Qing May 17 '18 at 23:39
  • 2
    @Uueerdo MySQL table names are tied to their filenames on disk. If the database's filesystem is case sensitive (most Unixes) your table names will be case sensitive. If they're not (Windows, Macs) they won't be. But this is a MySQL quirk. It is ***a very bad habit*** to assume table names will be case-insensitive. It is safest to assume they are case-sensitive. This goes for most of MySQL's quirks. – Schwern May 17 '18 at 23:41
  • @Schwern I am fairly certain MySQL has a "force case insensitive" configuration setting. ...either way, standard practice is to keep table names lower case to avoid issues that could arise transitioning between windows and `nix hosts. – Uueerdo May 17 '18 at 23:48
  • Never use evil `SELECT *`. Always name (and qualify) the columns you actually want returned – Strawberry May 17 '18 at 23:50

0 Answers0