sql语句学习贴,不断更新!
1. select between用法:
2. 同一个select语句获得两个表的内容:
分类id在7和9之间的:
SelectCommand="SELECT top 8 [id], [Clid], [Title], [TitleColor], [Ontop], [Hot], [AddTime] FROM [Article] WHERE [Clid] between 7 and 9 ORDER BY [Ontop], [Hot], [id] desc"
分类id不在7和9之间的:
SelectCommand="SELECT top 8 [id], [Clid], [Title], [TitleColor], [Ontop], [Hot], [AddTime] FROM [Article] WHERE [Clid] not between 7 and 9 ORDER BY [Ontop], [Hot], [id] desc"
SelectCommand="SELECT top 8 [id], [Clid], [Title], [TitleColor], [Ontop], [Hot], [AddTime] FROM [Article] WHERE [Clid] between 7 and 9 ORDER BY [Ontop], [Hot], [id] desc"
分类id不在7和9之间的:
SelectCommand="SELECT top 8 [id], [Clid], [Title], [TitleColor], [Ontop], [Hot], [AddTime] FROM [Article] WHERE [Clid] not between 7 and 9 ORDER BY [Ontop], [Hot], [id] desc"
2. 同一个select语句获得两个表的内容:
1select A.OrderNum,A.Product_Id,A.BuyPrice,A.ProdUnit,C.Title,C.Buy_Price from OrderDetail A,Products C where A.OrderNum='"&id&"' and A.Product_Id=C.Product_Id"