Edited to support price filter
You can use the INNER JOIN to join these tables. This is done as follows:
select p.id, p.name as ProductName, a.userid, a.name as AgentName from products p inner join agents a on a.userid = p.agentid where p.price < 100
Another way to do this is with the WHERE :
select p.id, p.name as ProductName, a.userid, a.name as AgentName from products p, agents a where a.userid = p.agentid and p.price < 100
Note that in the second case, you make a natural product of all the rows from both tables and then filter the result. In the first case, you directly filter the result, joining the same step. The DBMS will understand your intentions (no matter how you decide to solve it) and process it in the fastest way.
Mosty mostacho
source share