Hi,
this is different (old) SQL dialect, where WHERE condition is similar to INNER JOIN.
There is nothing magic in translation. In Your example
employees.manager = managers.id act the same role as Michael's
INNER JOIN managers AS m ON e.manager = m.id , rest of Your WHERE is simple condition to find employee 'Carlos' and related manager - relation is because previous WHERE condition exists.
Please notice, that displayed columns depend on SELECT statement, I mean SELECT and list of columns You want to display.
Regards,
Bartek
2012/2/9 Carlos Mennens
<carlos.mennens@gmail.com>On Thu, Feb 9, 2012 at 11:28 AM, Michael Wood <
esiotrot@gmail.com> wrote:
> Try something like this:
>
> SELECT e.fname AS emp_fname, e.lname AS emp_lname,
m.name AS manager
> FROM employees AS e
> INNER JOIN managers AS m ON e.manager =
m.id > WHERE e.salary = 12345.67;
I'm going to try this now but while I was working on this in pgAdmin3
query builder tool, I got the results I wanted which was to just query
my employee table and translate the employees.manager field from
INTEGER to their actual name referenced in 'managers.name' as show
below:
psql (9.1.2)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
zoo=# SELECT
employees.id,
employees.fname,
employees.lname,
managers.name AS manager
FROM
employees,
managers
WHERE
employees.manager = managers.id AND employees.fname = 'Carlos';
id | fname | lname | manager
----+--------+---------+---------------
1 | Carlos | Mennens | Phill Collins
(1 row)