首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在幼虫中分别获得最大数量和所有其他数量?

如何在幼虫中分别获得最大数量和所有其他数量?
EN

Stack Overflow用户
提问于 2019-09-27 08:29:02
回答 1查看 49关注 0票数 0

你好,我正在建立一个拍卖系统。现在我将考虑两个表。拍卖表和投标表。我想建立雄辩的查询,以便我可以获得最大金额和所有其他金额分开,因为我将转移最大金额给卖家和其他金额,以退款他们的用户。

我不知道我应该从哪里开始。

拍卖表迁移

代码语言:javascript
复制
   public function up()
    {
        Schema::create('auctions', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->Integer('productID');
            $table->Integer('price');
            $table->Integer('quantity');
            $table->dateTime('endTimeDate');
            $table->dateTime('startTimeDate');
            $table->timestamps();
        });
    }

投标表迁移

代码语言:javascript
复制
  public function up()
    {
        Schema::create('biddings', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->Integer('userID');
            $table->integer('auctionID');
            $table->bigInteger('amount');
            $table->timestamps();
        });
    }

我想要最大金额和其他金额分开。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-27 08:38:41

由于金额只是一个整数,因此检索所有金额并从集合中弹出最大值

代码语言:javascript
复制
$other_amounts = \DB::table('biddings')->select('amount')->orderBy('amount')->get();
$maximum = $other_amounts->pop(); // this will get the maximum
echo $other_amounts; // Here are all the amounts except the maximum
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58126283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档