0

I have the following query that inserts data into table.

INSERT INTO linking (user, relaterd, type, changedate, changeuser, createdate, muser, id, common)
   SELECT map.user, mre.uuid,  'BALL',  TIMESTAMP '2019-11-03 00:00:00.000', 'system',  TIMESTAMP '2019-11-03 00:00:00.000',  'system',  uuid_generate_v4(), mre.uuid
   FROM (SELECT user FROM mapuser v JOIN mct m ON v.uid = m.groep) map
   JOIN (SELECT mr.uuid, mr.number FROM mre mr where mr.type = 'KCT') mre ON mre.number = substring(m.groep, 2, length(m.groep));

I want the columns "user", "relaterd" and "common" to be filled by the SELECT-JOIN statements. The columns "relaterd" and "common" have the same values. The other columns are constants.

When I execute this query, I get the ERROR MESSAGE :: missing FROM-clause entry for table "m". It's like it wants me to use From clause for the table "mct" which I think I don't need it because am JOINING it with mapuser table.

0

1 Answer 1

1

You don't have table m outside (SELECT user FROM mapuser v JOIN mct m ON v.uid = m.groep).

Try to replace m with map:

substring(map.groep, 2, length(map.groep))

In your query you have only tables map in FROM-clause and mre joined with it. Other tables' aliases exist only in subqueries.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.