SQL--工作中遇到的
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL--工作中遇到的相关的知识,希望对你有一定的参考价值。
--递归查询产品分类
WITH cte AS ( SELECT * FROM syn_Categories WHERE id = $CategoryID$ UNION ALL SELECT syn_Categories.* FROM cte aaa , syn_Categories WHERE aaa.id = syn_Categories.parentId AND aaa.id != 0 ) SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY a.SKU ) AS ROWID , a.* , ISNULL(d.NetStock, 0) AS NetStock, c.SupplierCode FROM MVPProduct a LEFT JOIN SupplyCommitment b ON a.SKU = b.SKU LEFT JOIN (SELECT SKU, ID, NetStock FROM MVPStockUp WHERE ID IN ( SELECT MAX(ID) FROM MVPStockUp GROUP BY SKU)) d ON a.SKU = d.SKU AND ( $CategoryID$ = 0 OR ( CategoryID IN ( SELECT ID FROM cte WHERE ID NOT IN ( SELECT DISTINCT ( ParentId ) FROM cte )) )) LEFT JOIN SupplierSumMerchandise c ON b.SupplierID = c.SupplierID WHERE a.Status = 1
以上是关于SQL--工作中遇到的的主要内容,如果未能解决你的问题,请参考以下文章
以下代码片段是不是容易受到 Rails 5 中 SQL 注入的影响?
代码片段使用复杂的 JavaScript 在 UIWebView 中插入 HTML?