mysql - Subquery returns more than 1 row sql query -
i had such error can explain did wrong?
add sql query:
(? = (select travel_region_id relationships travel_id = travels.id))
error
activerecord::statementinvalid (mysql::error: subquery returns more 1 row: select count(*) travel_start_days, cars, travels travels.id = travel_start_days.travel_id , travels.id = travel.car_id , travel_start_days.day > adddate(curdate(), interval '2' day) , (7 = (select travel_region_id relationships travel_id = travels.id)) , '2013-08-16' <= travel_start_days.day):
update whis method create query
def conditions = '' param = [] if @region && @region != '' += 'travels.region_id = ?' param += [@region.to_i] end if @car && @car != '' += ' , ' if != '' += 'cars.id = ?' param += [@car.to_i] end if @relation && @relation != '' += ' , ' if != '' += '(? = (select travel_region_id relationships travel_id = travels.id))' param += [@relation.to_i] end if @start_port && @start_port != '' += ' , ' if != '' += '(? = (select location_id travel_days travel_id = travel_start_days.travel_id , day_no = 1 order arrival asc limit 1))' param += [@start_port.to_i] end return == '' ? nil : ["travel_start_days.day > adddate(curdate(), interval ? day) , " + where] + [@criteria[5]] + param end
the issue in part of conditions:
(7 = (select travel_region_id relationships travel_id = travels.id))
obviously subquery returns more 1 travel_region_id
replace =
in
(7 in (select travel_region_id relationships travel_id = travels.id))
Comments
Post a Comment