phantom phantom - 4 months ago 8
MySQL Question

using innerJoins mysql

I have a table database called jobs with 2 tables. One is vacancies and the other is location. It looks something like this

VACANCIES
-----------
id|location

LOCATIONS
----------
id|country


I want to get the location number from the vacancies table and then use this to choose the id from the locations table. For example, if the location was 5 in the
VACANCIES
table I would want to use this number, put it as the id in the
LOCATIONS
table and get the corresponding country.

See my current attempt below.

SELECT * FROM careers.vacancies
INNER JOIN careers
ON careers.location.id=5;


My sql leaves a bit to be desired so please forgive me if my query is way off.

Answer
SELECT locations.id, locations.country FROM vacancies
INNER JOIN locations ON locations.id = vacancies.id;
Comments