问题描述
我使用ASP code即传统的ASP和SQL Server 2000在这个过程中显示来自数据库记录到表中。
我有两个环节叫周明智和月明智的。
当用户点击这个链接,他会看到数据一周明智或月明智假设数据库中有存储的所有日期的日期字段,当记录被插入。
到目前为止,我可以在表中显示的记录present为特定用户。如何显示他/她的记录,一周或一个月明智的。
这是我所使用的查询
<%
SQL =SELECT SUM(grand_total),为从ORDER_DETAILS总哪里emp_number ='与&的Request.QueryString(否)及'
rs.open SQL,CON,1,2-
这样做虽然不RS.EOF rs.movenext
循环
rs.close
%GT;
这个特定的查询显示特定结果的记录...
选择
emp_number,
DATEPART(年,order_date的)
日期部分(月,order_date的)
DATEPART(WK,order_date的)
总和(grand_total)
从ORDER_DETAILS
通过...分组
emp_number,
DATEPART(年,order_date的)
日期部分(月,order_date的)
DATEPART(WK,order_date的)
为了通过1,2,3,4
和我会考虑使用以prevent SQL注入。
I'm using asp code i.e classic ASP and SQL server 2000 in this process to display records from database into a table.I have two links called week-wise and month-wise . when the user clicks on this link he will see the data week-wise or month-wise assuming the database have a date field which stores all the dates, when the record is inserted.
So far i'm able to display records present in the table for that particular user. How can i display his/her records WEEK or MONTH wise.
this is the query that I have use
<%
sql="select SUM(grand_total) as total from order_details where emp_number='"&request.QueryString("no")&"'"
rs.open sql,con,1,2
do while not rs.eof
rs.movenext
loop
rs.close
%>
this particular query displays records of that particular result...
select
emp_number,
datepart(year, order_date),
datepart(month, order_date),
datepart(wk, order_date),
sum(grand_total)
from order_details
group by
emp_number,
datepart(year, order_date),
datepart(month, order_date),
datepart(wk, order_date)
order by 1, 2, 3, 4
And I'd consider using Prepared Statements to prevent SQL injection.
这篇关于经典ASP - 从DATABSE表中的周明智或月明智的显示记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!