select user's sector
Hi,
I have sectors table with the following:
sector_id
sector_name
following sample:
ID. Name
1. Technology
2. Agriculture
3. Education
and I have user_sectors table with the following:
user_id
sector_id
In user_sectors table I am entering the sectors which user is interested in, for example:
user_id. sector_id
999 1
999. 3
which means the user ID 999 is interested only in the technology and education sectors
I want to select all rows in sectors table and show a column indicate if the user is interested in every sector or not based on the user_sectors value so the result for user 999 when I select should look like this:
Sector. Interested
Technology. 1
Agriculture. 0
Education. 1
Here is what I tried but not working:
SELECT sectors.sector_id, sectors.sector_name, user_sectors.user_id
FROM sectors
LEFT JOIN user_sectors ON user_sectors.sector_id = sectors.sector_id
WHERE user_sectors.user_id = 999;
Subject
Written By
Posted
select user's sector
October 17, 2020 10:35AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.