| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
| 5 |
<link href="../sqlite.css" rel="stylesheet"> |
| 6 |
<title>SQLite Syntax: factored-select-stmt</title> |
| 7 |
<!-- path=../ --> |
| 8 |
</head> |
| 9 |
<body> |
| 10 |
<div class=nosearch> |
| 11 |
<a href="../index.html"> |
| 12 |
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0"> |
| 13 |
</a> |
| 14 |
<div><!-- IE hack to prevent disappearing logo --></div> |
| 15 |
<div class="tagline desktoponly"> |
| 16 |
Small. Fast. Reliable.<br>Choose any three. |
| 17 |
</div> |
| 18 |
<div class="menu mainmenu"> |
| 19 |
<ul> |
| 20 |
<li><a href="../index.html">Home</a> |
| 21 |
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a> |
| 22 |
<li class='wideonly'><a href='../about.html'>About</a> |
| 23 |
<li class='desktoponly'><a href="../docs.html">Documentation</a> |
| 24 |
<li class='desktoponly'><a href="../download.html">Download</a> |
| 25 |
<li class='wideonly'><a href='../copyright.html'>License</a> |
| 26 |
<li class='desktoponly'><a href="../support.html">Support</a> |
| 27 |
<li class='desktoponly'><a href="../prosupport.html">Purchase</a> |
| 28 |
<li class='search' id='search_menubutton'> |
| 29 |
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a> |
| 30 |
</ul> |
| 31 |
</div> |
| 32 |
<div class="menu submenu" id="submenu"> |
| 33 |
<ul> |
| 34 |
<li><a href='../about.html'>About</a> |
| 35 |
<li><a href='../docs.html'>Documentation</a> |
| 36 |
<li><a href='../download.html'>Download</a> |
| 37 |
<li><a href='../support.html'>Support</a> |
| 38 |
<li><a href='../prosupport.html'>Purchase</a> |
| 39 |
</ul> |
| 40 |
</div> |
| 41 |
<div class="searchmenu" id="searchmenu"> |
| 42 |
<form method="GET" action="../search"> |
| 43 |
<select name="s" id="searchtype"> |
| 44 |
<option value="d">Search Documentation</option> |
| 45 |
<option value="c">Search Changelog</option> |
| 46 |
</select> |
| 47 |
<input type="text" name="q" id="searchbox" value=""> |
| 48 |
<input type="submit" value="Go"> |
| 49 |
</form> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<script> |
| 53 |
function toggle_div(nm) { |
| 54 |
var w = document.getElementById(nm); |
| 55 |
if( w.style.display=="block" ){ |
| 56 |
w.style.display = "none"; |
| 57 |
}else{ |
| 58 |
w.style.display = "block"; |
| 59 |
} |
| 60 |
} |
| 61 |
function toggle_search() { |
| 62 |
var w = document.getElementById("searchmenu"); |
| 63 |
if( w.style.display=="block" ){ |
| 64 |
w.style.display = "none"; |
| 65 |
} else { |
| 66 |
w.style.display = "block"; |
| 67 |
setTimeout(function(){ |
| 68 |
document.getElementById("searchbox").focus() |
| 69 |
}, 30); |
| 70 |
} |
| 71 |
} |
| 72 |
function div_off(nm){document.getElementById(nm).style.display="none";} |
| 73 |
window.onbeforeunload = function(e){div_off("submenu");} |
| 74 |
/* Disable the Search feature if we are not operating from CGI, since */ |
| 75 |
/* Search is accomplished using CGI and will not work without it. */ |
| 76 |
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){ |
| 77 |
document.getElementById("search_menubutton").style.display = "none"; |
| 78 |
} |
| 79 |
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */ |
| 80 |
function hideorshow(btn,obj){ |
| 81 |
var x = document.getElementById(obj); |
| 82 |
var b = document.getElementById(btn); |
| 83 |
if( x.style.display!='none' ){ |
| 84 |
x.style.display = 'none'; |
| 85 |
b.innerHTML='show'; |
| 86 |
}else{ |
| 87 |
x.style.display = ''; |
| 88 |
b.innerHTML='hide'; |
| 89 |
} |
| 90 |
return false; |
| 91 |
} |
| 92 |
var antiRobot = 0; |
| 93 |
function antiRobotGo(){ |
| 94 |
if( antiRobot!=3 ) return; |
| 95 |
antiRobot = 7; |
| 96 |
var j = document.getElementById("mtimelink"); |
| 97 |
if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 98 |
} |
| 99 |
function antiRobotDefense(){ |
| 100 |
document.body.onmousedown=function(){ |
| 101 |
antiRobot |= 2; |
| 102 |
antiRobotGo(); |
| 103 |
document.body.onmousedown=null; |
| 104 |
} |
| 105 |
document.body.onmousemove=function(){ |
| 106 |
antiRobot |= 2; |
| 107 |
antiRobotGo(); |
| 108 |
document.body.onmousemove=null; |
| 109 |
} |
| 110 |
setTimeout(function(){ |
| 111 |
antiRobot |= 1; |
| 112 |
antiRobotGo(); |
| 113 |
}, 100) |
| 114 |
antiRobotGo(); |
| 115 |
} |
| 116 |
antiRobotDefense(); |
| 117 |
</script> |
| 118 |
<h1 align='center'>factored-select-stmt</h1> |
| 119 |
<div class='imgcontainer'> |
| 120 |
<div style="max-width:629px"><svg xmlns='http://www.w3.org/2000/svg' class="pikchr" viewBox="0 0 629.266 500.04"> |
| 121 |
<circle cx="5" cy="17" r="3.6" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 122 |
<polygon points="45,17 33,21 33,12" style="fill:rgb(0,0,0)"/> |
| 123 |
<path d="M9,17L39,17" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 124 |
<path d="M60,32L91,32A15 15 0 0 0 106 17A15 15 0 0 0 91 2L60,2A15 15 0 0 0 45 17A15 15 0 0 0 60 32Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 125 |
<text x="75" y="17" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">WITH</text> |
| 126 |
<path d="M166,62L252,62A15 15 0 0 0 267 47A15 15 0 0 0 252 32L166,32A15 15 0 0 0 151 47A15 15 0 0 0 166 62Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 127 |
<text x="209" y="47" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">RECURSIVE</text> |
| 128 |
<polygon points="209,17 197,21 197,12" style="fill:rgb(0,0,0)"/> |
| 129 |
<path d="M106,17L203,17" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 130 |
<polygon points="357,17 345,21 345,12" style="fill:rgb(0,0,0)"/> |
| 131 |
<path d="M209,17L351,17" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 132 |
<path d="M357,32L583,32L583,2L357,2Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 133 |
<text x="470" y="17" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">common-table-expression</text> |
| 134 |
<polygon points="151,47 139,51 139,43" style="fill:rgb(0,0,0)"/> |
| 135 |
<path d="M106,17 L 113,17 Q 121,17 121,32 L 121,32 Q 121,47 133,47 L 145,47" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 136 |
<polygon points="290,47 278,51 278,43" style="fill:rgb(0,0,0)"/> |
| 137 |
<path d="M267,47L284,47" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 138 |
<path d="M290,47 L 297,47 Q 305,47 305,32 L 305,32 Q 305,17 320,17 L 330,17 L 345,17" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 139 |
<path d="M470,70A15 15 0 0 0 485 55L485,55A15 15 0 0 0 470 39A15 15 0 0 0 455 55L455,55A15 15 0 0 0 470 70Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 140 |
<text x="470" y="55" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text> |
| 141 |
<polygon points="485,55 497,50 497,59" style="fill:rgb(0,0,0)"/> |
| 142 |
<path d="M583,17 L 591,17 Q 598,17 598,32 L 598,40 Q 598,55 583,55 L 506,55 L 491,55" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 143 |
<path d="M455,55 L 349,55 Q 334,55 334,40 L 334,32 Q 334,17 340,17 L 345,17" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 144 |
<path d="M117,153L220,153L220,123L117,123Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 145 |
<text x="169" y="138" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">select-core</text> |
| 146 |
<path d="M60,304L105,304A15 15 0 0 0 120 289A15 15 0 0 0 105 274L60,274A15 15 0 0 0 45 289A15 15 0 0 0 60 304Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 147 |
<text x="82" y="289" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">ORDER</text> |
| 148 |
<polygon points="143,289 131,293 131,285" style="fill:rgb(0,0,0)"/> |
| 149 |
<path d="M120,289L137,289" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 150 |
<path d="M158,304L162,304A15 15 0 0 0 177 289A15 15 0 0 0 162 274L158,274A15 15 0 0 0 143 289A15 15 0 0 0 158 304Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 151 |
<text x="160" y="289" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">BY</text> |
| 152 |
<path d="M60,410L93,410A15 15 0 0 0 109 395A15 15 0 0 0 93 380L60,380A15 15 0 0 0 45 395A15 15 0 0 0 60 410Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 153 |
<text x="77" y="395" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">LIMIT</text> |
| 154 |
<polygon points="132,395 120,399 120,390" style="fill:rgb(0,0,0)"/> |
| 155 |
<path d="M109,395L126,395" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 156 |
<path d="M132,410L181,410L181,380L132,380Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 157 |
<text x="156" y="395" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 158 |
<polygon points="117,138 105,142 105,133" style="fill:rgb(0,0,0)"/> |
| 159 |
<path d="M9,17 L 16,17 Q 24,17 24,32 L 24,123 Q 24,138 39,138 L 96,138 L 111,138" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 160 |
<polygon points="312,92 323,88 323,97" style="fill:rgb(0,0,0)"/> |
| 161 |
<path d="M583,17 L 604,17 Q 619,17 619,32 L 619,77 Q 619,92 604,92 L 333,92 L 318,92" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 162 |
<path d="M312,92 L 39,92 Q 24,92 24,100 L 24,107" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 163 |
<path d="M80,198L257,198L257,168L80,168Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 164 |
<text x="169" y="183" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">compound-operator</text> |
| 165 |
<polygon points="257,183 269,179 269,187" style="fill:rgb(0,0,0)"/> |
| 166 |
<path d="M272,138 L 280,138 Q 287,138 287,153 L 287,168 Q 287,183 275,183 L 263,183" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 167 |
<path d="M80,183 L 65,183 Q 50,183 50,168 L 50,153 Q 50,138 58,138 L 65,138" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 168 |
<polygon points="296,236 308,232 308,240" style="fill:rgb(0,0,0)"/> |
| 169 |
<path d="M220,138 L 342,138 Q 357,138 357,153 L 357,221 Q 357,236 342,236 L 317,236 L 302,236" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 170 |
<polygon points="45,289 33,293 33,285" style="fill:rgb(0,0,0)"/> |
| 171 |
<path d="M296,236 L 39,236 Q 24,236 24,251 L 24,274 Q 24,289 31,289 L 39,289" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 172 |
<polygon points="222,289 210,293 210,285" style="fill:rgb(0,0,0)"/> |
| 173 |
<path d="M177,289L216,289" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 174 |
<path d="M222,304L352,304L352,274L222,274Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 175 |
<text x="287" y="289" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">ordering-term</text> |
| 176 |
<path d="M287,342A15 15 0 0 0 302 327A15 15 0 0 0 287 312A15 15 0 0 0 272 327A15 15 0 0 0 287 342Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 177 |
<text x="287" y="327" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text> |
| 178 |
<polygon points="302,327 314,322 314,331" style="fill:rgb(0,0,0)"/> |
| 179 |
<path d="M352,289 L 359,289 Q 367,289 367,304 L 367,312 Q 367,327 352,327 L 323,327 L 308,327" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 180 |
<path d="M272,327 L 214,327 Q 199,327 199,312 L 199,304 Q 199,289 205,289 L 210,289" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 181 |
<polygon points="388,319 384,308 392,308" style="fill:rgb(0,0,0)"/> |
| 182 |
<path d="M352,289 L 373,289 Q 388,289 388,301 L 388,313" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 183 |
<polygon points="198,361 210,356 210,365" style="fill:rgb(0,0,0)"/> |
| 184 |
<path d="M388,319 L 388,346 Q 388,361 373,361 L 219,361 L 204,361" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 185 |
<polygon points="45,395 33,399 33,390" style="fill:rgb(0,0,0)"/> |
| 186 |
<path d="M198,361 L 39,361 Q 24,361 24,376 L 24,380 Q 24,395 31,395 L 39,395" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 187 |
<polygon points="24,327 20,315 28,315" style="fill:rgb(0,0,0)"/> |
| 188 |
<path d="M24,274L24,321" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 189 |
<path d="M24,327L24,380" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 190 |
<path d="M255,440L306,440A15 15 0 0 0 321 425A15 15 0 0 0 306 410L255,410A15 15 0 0 0 240 425A15 15 0 0 0 255 440Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 191 |
<text x="281" y="425" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">OFFSET</text> |
| 192 |
<polygon points="344,425 333,429 333,421" style="fill:rgb(0,0,0)"/> |
| 193 |
<path d="M321,425L339,425" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 194 |
<path d="M344,440L394,440L394,410L344,410Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 195 |
<text x="369" y="425" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 196 |
<polygon points="417,425 405,429 405,421" style="fill:rgb(0,0,0)"/> |
| 197 |
<path d="M394,425L411,425" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 198 |
<path d="M255,478A15 15 0 0 0 270 463A15 15 0 0 0 255 448A15 15 0 0 0 240 463A15 15 0 0 0 255 478Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 199 |
<text x="255" y="463" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text> |
| 200 |
<polygon points="293,463 282,467 282,458" style="fill:rgb(0,0,0)"/> |
| 201 |
<path d="M270,463L287,463" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 202 |
<path d="M293,478L342,478L342,448L293,448Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 203 |
<text x="318" y="463" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 204 |
<polygon points="204,395 192,399 192,390" style="fill:rgb(0,0,0)"/> |
| 205 |
<path d="M181,395L198,395" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 206 |
<polygon points="240,463 228,467 228,458" style="fill:rgb(0,0,0)"/> |
| 207 |
<path d="M204,395 L 211,395 Q 219,395 219,410 L 219,448 Q 219,463 226,463 L 234,463" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 208 |
<polygon points="240,425 228,429 228,421" style="fill:rgb(0,0,0)"/> |
| 209 |
<path d="M204,395 L 211,395 Q 219,395 219,410 L 219,410 Q 219,425 226,425 L 234,425" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 210 |
<polygon points="417,395 405,399 405,390" style="fill:rgb(0,0,0)"/> |
| 211 |
<path d="M204,395L411,395" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 212 |
<polygon points="619,493 608,497 608,489" style="fill:rgb(0,0,0)"/> |
| 213 |
<path d="M417,395 L 438,395 Q 453,395 453,410 L 453,478 Q 453,493 468,493 L 599,493 L 614,493" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 214 |
<circle cx="623" cy="493" r="3.6" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 215 |
<path d="M417,425 L 438,425 Q 453,425 453,433 L 453,440" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 216 |
<polygon points="417,463 405,467 405,458" style="fill:rgb(0,0,0)"/> |
| 217 |
<path d="M342,463L411,463" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 218 |
<path d="M417,463 L 438,463 Q 453,463 453,470 L 453,478" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 219 |
<polygon points="417,493 405,497 405,489" style="fill:rgb(0,0,0)"/> |
| 220 |
<path d="M24,380 L 24,478 Q 24,493 39,493 L 396,493 L 411,493" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 221 |
<path d="M417,493L489,493" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 222 |
</svg> |
| 223 |
</div><br> |
| 224 |
<br></br> |
| 225 |
References: <a href='./common-table-expression.html'>common-table-expression</a> <a href='./compound-operator.html'>compound-operator</a> <a href='./expr.html'>expr</a> <a href='./ordering-term.html'>ordering-term</a> <a href='./select-core.html'>select-core</a><br></br> |
| 226 |
See also: <a href='../lang_select.html'>lang_select.html</a> |
| 227 |
</div> |
| 228 |
|
| 229 |
|
| 230 |
|