Skip to content

希望egg-mysql支持在select字段列中写子查询 #5761

@ymsh

Description

@ymsh

请详细告知你的新点子(Nice Ideas):

  1. 希望egg-mysql支持在select字段列中写子查询
    如:
SELECT id, username, nickname, login_type, 
  (SELECT SUM(times) FROM remoter_device_use AS du 
   WHERE du.user_id = sys_user.id AND du.times > 0) AS use_times 
FROM sys_user WHERE deleted = 0 
ORDER BY use_times DESC, id DESC 
LIMIT 0, 10

我使用这种写法会出现sql错误(SELECT SUM(times) FROM remoter_device_use AS du WHERE du.user_id = sys_user.id AND times > 0) AS use_times不是字段

this.app.mysql.select('sys_user', {
    columns: [
      'id',
      'username',
      'nickname',
      'login_type',
      '(SELECT SUM(times) FROM remoter_device_use AS du WHERE du.user_id = sys_user.id AND times > 0) AS use_times'
    ],
    where,
    orders: [
      [ 'use_times', 'DESC' ],
      [ 'id', 'DESC' ]
    ],
    limit: pageSize,
    offset
  });
  1. 希望egg-mysql查询支持写and or条件混合。
    egg-mysql的支持实在太弱了。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions