G
G
gowwa1232020-11-04 16:10:32
PostgreSQL
gowwa123, 2020-11-04 16:10:32

Missing FROM-clause entry for table " "", what to do?

In the column, I indicated which table to take from, and he writes to me that there is no entry from the sentence for the "users" table, what should I do?

spoiler
5fa2a7b6d64ad076313366.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Vodakov, 2020-11-04
@gowwa123

In FROM, you need to specify the teterika.users table and the condition for linking to the teterika.lessons table.
if the condition is not specified, then each row of one table will be associated with each row of another table, a Cartesian product of the tables will be obtained.

SELECT 
  tl.subject,
  tu.role
FROM teterika.lessons AS tl, teterika.users AS tu
WHERE teterika.users.role = 'tutor'

By the way, your request does not make sense, because from teterika.users.role you will only extract the 'tutor' entry in accordance with the condition. Those. your request can be replaced with:
SELECT 
  tl.subject,
  'tutor' AS role
FROM teterika.lessons

Unless you really need to get the cartesian product of all lessons with all teachers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question