mysql根据多个字段的数据计算排序

select *,num1+num2*10+num3*100 num from $tableName  order by num desc

 

yii2框架活动记录activeRecord添加默认字段

$query =(new \yii\db\Query())
        ->select([
               'table.*',
          new Expression("'身份证' id_no_type")
              ])
             ->from(['table' => $this->tableName()])

 

yii2框架活动记录activeRecord添加计算字段

$query =(new \yii\db\Query())
        ->select([
               'table.*',
          new Expression("views_num+collect_num*10+share_num*100 new_sort")
              ])
             ->from(['table' => $this->tableName()])

 

相关文章:

  • 2022-12-23
  • 2022-01-04
  • 2021-09-08
  • 2022-12-23
  • 2021-11-30
  • 2022-02-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-18
  • 2021-12-14
相关资源
相似解决方案