如何从两个日期之间的mysql查询中获取数据?

发布于 2024-10-30 17:01:22 字数 1275 浏览 1 评论 0原文

我正在寻找一种方法来获取两个日期之间的数据,为此我使用下面的查询,

SELECT  tbl_docuserstatus.*,tbl_doc.doc_assoc_id,tbl_doctype.doctype_id,tbl_doctype.doctype_name,tbl_doc.doc_reference_number,tbl_doc.doc_date,tbl_doc.doc_start,tbl_doc.creator_id,tbl_doc.control_id,tbl_doc.company_id,tbl_doc.vendor_id,tbl_doc.amount,tbl_doc.currency,tbl_doc.paid,tbl_doc.urgent,tbl_dompany.company_name,tbl_dompany.company_code,tbl_vendor.vendor_name 
                FROM
                     tbl_docuserstatus
                LEFT JOIN
                    tbl_doc ON tbl_doc.doc_id = tbl_docuserstatus.doc_id
                LEFT JOIN
                    tbl_doctype ON tbl_doctype.doctype_id = tbl_doc.doctype_id
                LEFT JOIN
                    tbl_company ON tbl_company.company_id =  tbl_doc.company_id 
                LEFT JOIN 
                    tbl_vendor ON tbl_vendor.vendor_id = tbl_doc.vendor_id
                LEFT JOIN 
                    tbl_users ON tbl_users.user_id = tbl_doc.creator_id 
                WHERE
                     payment_status = '0' AND tbl_doc.company_id='1' AND  AND tbl_doc.doctype_id = '1' AND tbl_doc.doc_date BETWEEN '2011-04-05 00:00:00' AND '2011-04-07 00:00:00'

上面的查询给了我语法错误,所以有人可以告诉我,

如何从两个日期之间的mysql查询中获取数据?

I am Looking for a way to fetch the data between two date, for which I am using below query,

SELECT  tbl_docuserstatus.*,tbl_doc.doc_assoc_id,tbl_doctype.doctype_id,tbl_doctype.doctype_name,tbl_doc.doc_reference_number,tbl_doc.doc_date,tbl_doc.doc_start,tbl_doc.creator_id,tbl_doc.control_id,tbl_doc.company_id,tbl_doc.vendor_id,tbl_doc.amount,tbl_doc.currency,tbl_doc.paid,tbl_doc.urgent,tbl_dompany.company_name,tbl_dompany.company_code,tbl_vendor.vendor_name 
                FROM
                     tbl_docuserstatus
                LEFT JOIN
                    tbl_doc ON tbl_doc.doc_id = tbl_docuserstatus.doc_id
                LEFT JOIN
                    tbl_doctype ON tbl_doctype.doctype_id = tbl_doc.doctype_id
                LEFT JOIN
                    tbl_company ON tbl_company.company_id =  tbl_doc.company_id 
                LEFT JOIN 
                    tbl_vendor ON tbl_vendor.vendor_id = tbl_doc.vendor_id
                LEFT JOIN 
                    tbl_users ON tbl_users.user_id = tbl_doc.creator_id 
                WHERE
                     payment_status = '0' AND tbl_doc.company_id='1' AND  AND tbl_doc.doctype_id = '1' AND tbl_doc.doc_date BETWEEN '2011-04-05 00:00:00' AND '2011-04-07 00:00:00'

here the above query given me syntax error, so could some one tell me,

How to get DATA from a mysql query bewtween two dates?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千纸鹤带着心事 2024-11-06 17:01:22

中删除此附加 AND

payment_status = '0' AND tbl_doc.company_id='1' AND  AND tbl_doc.doctype_id = '1' AND

从您的查询

payment_status = '0' AND tbl_doc.company_id='1' AND tbl_doc.doctype_id = '1' AND 

Remove this additional AND from you query

payment_status = '0' AND tbl_doc.company_id='1' AND  AND tbl_doc.doctype_id = '1' AND

To

payment_status = '0' AND tbl_doc.company_id='1' AND tbl_doc.doctype_id = '1' AND 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文