2014-01-13 5 views
3

mysql의 TSP (여행사 문제) 솔루션으로 작업 중입니다. 내가 쿼리mysql에서 인라인 쿼리를 실행하는 방법

-- variable coming from java 

    CREATE PROCEDURE solve_tsp(
    inout ids varchar(21845); 
    ) 
    begin 
    declare ret_ids varchar(21845); 
    -- some code 

    while length(ids) > 0 do 

    -- some assignment 
     SELECT to_id,distance into @l_tmp_id,@l_distance FROM mst_distance_matrix WHERE from_id =',@l_tmp_id,' AND 
to_id IN (ids) -- ids is variable contains comma delimited string. 
order by distance desc limit 1 

    -- concat value of to_id in ret_ids variable and then remove from ids variable 

    end while; 

    select ret_ids; 
    end; 

답변

관련 문제