uTools-Manuals/docs/sql/FORMAT() 函数.html
2019-05-07 10:15:08 +08:00

27 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="m-bg">
<h1>SQL FORMAT() 函数</h1>
<h2>FORMAT() 函数</h2> <p>FORMAT() 函数用于对字段的显示进行格式化。</p> <h3>SQL FORMAT() 语法</h3> <div class="code notranslate"><pre><code class="language-sql"><div> SELECT FORMAT(column_name,format) FROM table_name;</div></code></pre></div> <br/><table class="reference notranslate">
<tr>
<th align="left" valign="top" width="20%">参数</th> <th align="left" valign="top" width="80%">描述</th> </tr>
<tr>
<td valign="top">column_name</td> <td valign="top">必需。要格式化的字段。</td> </tr>
<tr>
<td valign="top">format</td> <td valign="top">必需。规定格式。</td> </tr>
</table>
<h2>演示数据库</h2> <p>在本教程中,我们将使用众所周知的 Northwind 样本数据库。</p> <p>下面是选自 "Products" 表的数据:</p> <table class="reference notranslate">
<tr>
<th>ProductID</th> <th>ProductName</th> <th>SupplierID</th> <th>CategoryID</th> <th>Unit</th> <th>Price</th> </tr>
<tr>
<td>1</td> <td>Chais</td> <td>1</td> <td>1</td> <td>10 boxes x 20 bags</td> <td>18</td> </tr>
<tr>
<td>2</td> <td>Chang</td> <td>1</td> <td>1</td> <td>24 - 12 oz bottles</td> <td>19</td> </tr>
<tr>
<td>3</td> <td>Aniseed Syrup</td> <td>1</td> <td>2</td> <td>12 - 550 ml bottles</td> <td>10</td> </tr>
<tr>
<td>4</td> <td>Chef Anton's Cajun Seasoning</td> <td>2</td> <td>2</td> <td>48 - 6 oz jars</td> <td>21.35</td> </tr>
<tr>
<td>5</td> <td>Chef Anton's Gumbo Mix</td> <td>2</td> <td>2</td> <td>36 boxes</td> <td>25</td> </tr>
</table>
<h2>SQL FORMAT() 实例</h2> <p>下面的 SQL 语句从 "Products" 表中选取产品名称以及当天(格式化为 YYYY-MM-DD的价格</p> <div class="example margin-b-10"> <h2 class="example">实例</h2> <pre><code class="language-sql"><div class="example_code notranslate"> SELECT ProductName, Price, FORMAT(Now(),'YYYY-MM-DD') AS PerDate<br/>FROM Products; </div></code></pre> </div> <div class="text-center padding-10 margin-t-5">
</div>
</div>