Look at the long SQL query example below. In this case, the WITH clause is basically a replacement for a normal subquery. The WITH clause allows you to name a subquery block and treat it like a normal table. If you inherit a chunk of un-indented code, there are a lot of sites that let you format your long SQL query for free. Indentation is the first thing you should do when you start to write code. To help you get started, I’ve provided links to style guides by ApexSQL and Simon Holywell. Even so, your indentation style should make sense to others. Every company or programmer usually develops their own. There is no single accepted indentation style. Without indentation, such long SQL query example will be very hard to read and understand! Now, imagine that there are 100 similar instructions, too. SELECT column1, column2 FROM table1 WHERE column3 IN ( SELECT TOP(1) column4 FROM table2 INNER JOIN table3 ON lumn1 = lumn1) Let’s see a relatively long SQL query example: When you correctly indent your code, you can quickly see what you are selecting, which tables provide the data, and what restrictions apply to it (i.e. This makes program structure more understandable and enables developers to easily find a specific instruction. Indentation helps keep your long SQL query clean by identifying where each block of code begins. How to Organize SQL Queries Tip 1: Indent Your Code
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |