select cc.id,cc.city_id from city_course_details cc inner join city c
on cc.city_id=c.id
where c.cityname='your city name'
as far as i understood your question this is what you are looking for.
if this is not what you want then once again ask me some more clearly.
you can write this query in stored procedure.