日期:2014-05-19  浏览次数:20939 次

这两句SQL语句那个是标准写法?
select  
a.orderid, a.hotelname, b.guestname,
a.roomname, c.roomprice, a.startdate,
a.enddate, b.enddate   enddate2, a.hotelId,
b.roomno, b.remark, a.TouchName,
a.TouchTel, a.TouchFax
from  
hotelorder   a,
hotelorderdetail   b,
hotelorderprice   c
where  
1=1
-- and   a.userId={0}
and   a.orderid=b.orderid  
and   b.enddate> =getdate()  
and   c.roomId=b.roomId  
and   a.useraudited=0   --未审计
and   b.checkinstatus=15   --NoShow
or     b.checkinstatus=15 --提前离店


SELECT   a.OrderId,   a.HotelName,   b.GuestName,   a.RoomName,   c.RoomPrice,   a.StartDate,  
            a.EndDate,   b.EndDate   AS   enddate2,   a.HotelId,   b.RoomNO,   b.Remark,   a.TouchName,  
            a.TouchTel,   a.TouchFax
FROM   dbo.HotelOrder   a   CROSS   JOIN
            dbo.HotelOrderDetail   b   CROSS   JOIN
            dbo.HotelOrderPrice   c
WHERE   (1   =   1)   AND   (a.OrderId   =   b.OrderId)   AND   (b.EndDate   > =   GETDATE())   AND  
            (c.RoomId   =   b.RoomId)   AND   (a.UserAudited   =   0)   AND   (b.CheckInStatus   =   15)   OR
            (b.CheckInStatus   =   15)

------解决方案--------------------
一样的结局,何来标准不标准阿,不过第二种看着整齐罢了


===================================================
技术交流不该有界限 资源共享不该有条件
博客空间:http://blog.csdn.net/lovingkiss
资源下载:http://download.csdn.net/user/lovingkiss
Email:loving-kiss@163.com
本人说明: <我的帖子我做主,结贴率保持100%>
1、欢迎一切问题有关的交流——无论答案对错;
2、不欢迎 顶、Mark、支持之类口水混分的人;
我保留对非 <散分贴> 蹭分者的厌恶和鄙视...
精通:jīnɡtōnɡ对学问技术等透彻的了解并熟练掌握
所以,我没有精通,只有JZ
===================================================
------解决方案--------------------
顶1!