给定的mysql查询没有返回任何数据
SELECT DISTINCT users.* FROM type_b_services JOIN users ON
users.userid=type_b_services.userid WHERE type_b_services.offer = 'A'
AND type_b_services.where_you_based = 'Domestic' AND
type_b_services.origin_country = 'United States' AND
type_b_services.origin_city = 'seattle' AND
type_b_services.destination_country = 'United States' AND
type_b_services.destination_city = 'San Francisco' AND
TRIM(DATE_FORMAT(type_b_services.travel_date,"%Y-%m")) =
TRIM(DATE_FORMAT('2016-02-22',"%Y-%m"))
但是这一行返回1行
SELECT DISTINCT users.* FROM type_b_services JOIN users ON
users.userid=type_b_services.userid WHERE type_b_services.offer = 'A'
AND type_b_services.where_you_based = 'Domestic' AND
type_b_services.origin_country = 'United States' AND
type_b_services.origin_city = 'seattle' AND
type_b_services.destination_country = 'United States' AND
type_b_services.destination_city` = 'San Francisco'
我发现这种情况打破了数据。
TRIM(DATE_FORMAT(type_b_services.travel_date,“%Y-%m”))= TRIM(DATE_FORMAT( '2016年2月22日', “%Y-%M”))
但是下面的代码返回18列,包括第二次查询的结果
SELECT id, DATE_FORMAT(type_b_services.travel_date, "%Y-%m") ,
DATE_FORMAT("2016-02-06", "%Y-%m") FROM `type_b_services`
WHERE
TRIM(DATE_FORMAT(type_b_services.travel_date,"%Y-%m")) =
TRIM(DATE_FORMAT('2016-02-22',"%Y-%m"))