简体   繁体   English

如何从SQL数据库中检索记录匹配的MemberID,月份和年份

[英]How to retrieve record match memberID, month and year from sql database

This might be a stupid question but i failed to do through tutorial found online, i got a table call tblPOS inside got item,quantity,total,memberid,posdate now i gonna retrieve match information for report end of the month what the form do is ask a member id , and month + year he want to see 这可能是一个愚蠢的问题,但我无法通过在线找到的教程来完成,我在表中调用了tblPOS,其中现在有item,quantity,total,memberid,posdate,现在我将检索匹配信息以获取月末报表的格式询问会员编号,以及他想查看的月份和年份

May i know how could i find the match record first check member id, then extract month and year from tblPOS of posdate finally get ONLY record match month and year request for specific member ? 我可以知道如何首先找到会员记录的匹配记录,然后从posdate的tblPOS中提取月份和年份,最后仅获得特定会员的记录匹配年份和月份的请求吗?

Thx in advance =D 提前Thx = D

Your question is unclear, however this query might get you started: 您的问题尚不清楚,但是此查询可能使您入门:

SELECT *
FROM tblPOS
WHERE MemberID = {memberID}
  AND posdate >= '2011-02-01' AND postdate < '2011-03-01'

You can use the sql DATEPART() function, however it is better to format the query with the date range, that way indexes can be used. 您可以使用sql DATEPART()函数,但是最好使用日期范围来格式化查询,这样可以使用索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从MVC模型中的SQL Server数据库中检索一条记录 - How to retrieve one record from SQL Server database in MVC Model linq to sql,从日期数组中选择与月份和年份匹配的日期 - linq to sql, select by dates that match to month and year from dates array 比较月份和年份的sql数据库 - Comparing a month and year sql database 有什么方法可以从 SQLDatabase C# 检索一年中任何一个月的所有记录 - Is there any way that l can retrieve all record of any month of the year from SQLDatabase C# 我想从MySQL数据库中检索去年的记录,但它正在从数据库中检索所有数据 - I want to retrieve last year record from MySQL database but it's retrieving all data's from database 如何根据从组合框中选择的月份和年份在数据库中进行搜索? - How to Search in the database according to Month and Year chosen from Combo Boxes? 如何一次从MVC模型的SQL Server数据库中检索一条记录 - How to retrieve one record at a time from SQL Server database in MVC Model 如何在不使用游标的情况下从数据库中检索一条特定记录? - How to retrieve one particular record from a database without using cursors? 如何从SQL数据库中检索多列? - How to retrieve multiple column from SQL database? 如何从View编辑SQL数据库中的记录 - How to edit a record in an SQL database from a View
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM