Join tables with same keys, second table has multiple values for key
You have two possibilities:


Two joins. Probably a good alternative if you do a limited search, and don't want all available attributes (i.e.: you ignore capital)

SELECT
    hostname, 
    type_var.varvalue AS `type`, 
    location_var.varvalue AS location
FROM
    hosts
    JOIN vars AS type_var  
        ON (type_var.object_id = hosts.host_object_id) AND  type_var.varname = 'type'
    JOIN vars AS location_var 
        ON (location_var.object_id = hosts.host_object_id) AND location_var.varname = 'location' ;

max(case) and GROUP BY. This is a typical approach to unpivot in standard SQL. This is normally faster went you either want all attributes (type, location, capital), or you don't limit your queries with a WHERE that restricts the result significantly. (In your case, without WHERE, I'd choose this approach:

SELECT
    hostname, 
    max(case when varname = 'type'     then varvalue end) AS `type`, 
    max(case when varname = 'location' then varvalue end) AS location
FROM
    hosts
    JOIN vars 
        ON (vars.object_id = hosts.host_object_id) 
GROUP BY
    object_id ;



In both cases, you'll get:


hostname | type    | location
:------- | :------ | :-------
America1 | Country | N.A.    
Another1 | Another | Location




NOTE 1: This assumes that vars has PRIMARY KEY (object_id, varname). Otherwise, you could have more than one type or location per object_id, and that would give you more than one row per object_id in the first case, and just one in the second, choosing the max among them.

NOTE 2: These queries are standard SQL and should work not only on MySQL, but on most SQL RDBMS.



You can check everything at dbfiddle here