Looks like some needs to catch up on the term 'NORMALIZATION' ...
Don't store diffent kinds of data in one table/column ...
That is, value is either a Country, a State, a City, a Participant ... but not all of them. So the problem lies in the database structure, not the query ... what you want to achieve with the given table structure is 'somewhat complicated'.
... at least, that what I kind of understand from it.