本文介绍了MySQL的.一段时间内未售出的产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习MySQL,但有一个问题.我有以下任务,对我来说这是很新的,但是从逻辑上讲这很容易.

I am learning MySQL and I have a question.I have this following assignment and it's pretty new to me, but logically it's easy.

我有下表:

 id          article_id   quantity     date_sold   price
  1                1            2      2014-05-05    200
  2                2            4      2014-05-12    800
  3                3            5      2014-05-02     35
  4                4            10     2014-05-18     60
  5                5            20     2014-05-23     20
  6                6            2      2014-05-20     26
  7                7            1      2014-05-14     10
  8                8            2      2014-05-12     30
  9                9            6      2014-05-11     12
  10               10           2      2014-05-08      6

问题听起来像这样:确定在特定时期内未售出的商品.结果听起来像这样:在2014-05-10和2014-05-20之间,没有售出第1、3、5、10条.

And the question sounds like this "Determine the article not sold in a given period.The result would pretty much sound like this:Between 2014-05-10 and 2014-05-20, article 1, 3, 5, 10 have not been sold.

推荐答案

尝试一下

  SELECT * from table1
  WHERE id NOT IN ( select id FROM table1 WHERE
             `date_sold` BETWEEN '2014-05-10' and '2014-05-20')

这将为您提供在指定日期之间未售出的商品的结果.

this will give you result of articles which have not been sold between the given dates.

此处演示

这篇关于MySQL的.一段时间内未售出的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:16