你好,我正在建立一个拍卖系统。现在我将考虑两个表。拍卖表和投标表。我想建立雄辩的查询,以便我可以获得最大金额和所有其他金额分开,因为我将转移最大金额给卖家和其他金额,以退款他们的用户。
我不知道我应该从哪里开始。
拍卖表迁移
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();
});
}投标表迁移
public function up()
{
Schema::create('biddings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->Integer('userID');
$table->integer('auctionID');
$table->bigInteger('amount');
$table->timestamps();
});
}我想要最大金额和其他金额分开。
发布于 2019-09-27 08:38:41
由于金额只是一个整数,因此检索所有金额并从集合中弹出最大值
$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 maximumhttps://stackoverflow.com/questions/58126283
复制相似问题