Open NemophilistWatermelon opened 1 month ago
let firstSql = sql.table('tb_parking_car').field( isDel, action, id, carNumber, carOwer, carStatus, startTime, endTime, pastDueStatus, address, ps, phoneNum, link_parking_lot_number as parkingId ).order(conditionsOrder).select()
isDel, action, id, carNumber, carOwer, carStatus, startTime, endTime, pastDueStatus, address, ps, phoneNum, link_parking_lot_number as parkingId
let querySql = sql.table(firstSql) .field(` ss.isDel, ss.action, ss.id, ss.carNumber, ss.carOwer, ss.carStatus, ss.startTime, ss.endTime, ss.pastDueStatus, ss.address, ss.ps, ss.phoneNum, ss.parkingId, ct.cityName, ct.id as cityId, pl.parkingName, pl.area as area, pl.city as city, pl.province as province`) .alias('ss') .join(joinParams) .where(where) .limit((form.page - 1) * form.pageSize, form.pageSize) .select() 生成的语句是:(放在mysql 里面可以直接运行,引入mysql2 执行query 也可以运行,但是 调用exec 方法,会提示某个列不存在) SELECT ss.isDel, ss.action, ss.id, ss.carNumber, ss.carOwer, ss.carStatus, ss.startTime, ss.endTime, ss.pastDueStatus, ss.address, ss.ps, ss.phoneNum, ss.parkingId, ct.cityName, ct.id as cityId, pl.parkingName, pl.area as area, pl.city as city, pl.province as province FROM (SELECT isDel, action, id, carNumber, carOwer, carStatus, startTime, endTime, pastDueStatus, address, ps, phoneNum, link_parking_lot_number as parkingId FROM tb_parking_car ORDER BY startTime desc ) ss RIGHT JOIN tb_parking_community ct ON (ct.isDel='0' ) LEFT JOIN tb_parking_lot pl ON ((ss.parkingId=pl.id) ) AND (ct.isDel='0' ) AND ((ct.id=pl.com_ity_id) ) WHERE ((pl.isDel='0') ) LIMIT 0,10
不好意思, 我搞错了, 库没问题,抱歉。。。。
let firstSql = sql.table('tb_parking_car').field(
isDel, action, id, carNumber, carOwer, carStatus, startTime, endTime, pastDueStatus, address, ps, phoneNum, link_parking_lot_number as parkingId
).order(conditionsOrder).select()