【发布时间】:2021-10-23 18:37:51
【问题描述】:
我要实现如下sql查询:
date_count = await customQuery(
`
SELECT
COUNT(org.name
OR c.name
OR co.name
OR seg.arrival_details
OR seg.departure_details
OR seg.segment_airline_id
OR seg.segment_arrival_airport_code
OR seg.segment_departure_airport_code
OR seg.segment_flight_number
OR seg.trip_id
OR b.trip_id
OR bf.pnr_no
OR bf.airline_pnr_no
OR b.booking_status
OR b.created
OR org.organisation_id
OR org.name
) AS total_count
FROM
segment_details AS seg
LEFT JOIN trip_details AS tr ON seg.trip_id = tr.trip_id
LEFT JOIN bookings_flight AS bf ON tr.bookings_flight_id = bf.booking_flight_id
LEFT JOIN bookings AS b ON bf.booking_id = b.booking_id
LEFT JOIN organisation AS org ON b.organisation_id = org.organisation_id
LEFT JOIN city AS c ON org.city_id = c.city_id
LEFT JOIN country AS co ON org.country_id = co.country_id
WHERE
seg.segment_departure_date BETWEEN
${moment(date.startDate).startOf('day').format("YYYY-MM-DD HH:mm:ss") }
AND ${moment(date.endDate).endOf('day').format("YYYY-MM-DD HH:mm:ss")}
`)
但我收到以下错误:
UnhandledPromiseRejectionWarning: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00:00:00
我的日期结果如下: '2021-10-01T08:00:00.000Z'
当我将 moment js 应用到它时,我的结果如下: '2021-10-01 00:00:00'
我正在使用 MySQL,SQL Yog
如何解决此错误?任何帮助或建议将不胜感激。
【问题讨论】: