,

SFWGHO – A Way to Remember the Order of Commands in SQL

The Downside – SFWGHO

When writing T-SQL, Microsoft's tackle the SQL database language, the instructions have to return in a sure order. That is:

– SELECT (choosing information)

– FROM (stating which desk to get information from)

– WHERE (any filtering situations)

– GROUP BY (specifying any settlement to carry out)

– HAVING (any filtering to carry out on aggregated information)

– ORDER BY (which order to show the ultimate rows in)

It’s critical that you simply put these instructions in the appropriate order, in any other case you'll get a syntax error. The acronym for the instructions is SFWGHO, so it's actually only a query of discovering a method to bear in mind this sequence of letters.

Options

When he first met this drawback, the writer of this text trawled the Web for acronyms. I discovered one web site which was working a contest, with one entrant:

Slippery Fish Will Garnish Hungry Orcas

Certainly there have to be higher acronyms than that! Somewhat reflection got here up with the next concepts:

Six Fats Wives Gross Husbands Out

Sweaty Ft Will Give Horrible Odours

Out of those, the second appears to be like higher (it's definitely in higher style!). So right here is our advice for the right way to bear in mind the order of instructions in SQL:

SWEATY or SELECT

FEET or FROM

WILL or WHERE

GIVE or GROUP BY

HORRIBLE or HAVING

ODOURS or ORDER BY

So now there's no excuse for getting the order of SQL instructions flawed, we simply must discover a method to bear in mind to place commas in the appropriate place on a regular basis …

Leave a Reply

Your email address will not be published. Required fields are marked *

You Need Central Online Data Storage, No Inconsistency and Redundancy

Mobile Apps For Business – The Power Is in the PUSH