Answer the question
In order to leave comments, you need to log in
Is the last record in the master table related to the child?
Hello. Do not prompt how correctly to implement. You need to select the last record in the parent1 table and then all the records from the child1 table related by key.
Or is there a better solution? Thanks.
SELECT "product_id", "amount" FROM"child1" WHERE "child1"."parent_id" = (SELECT "product_id", "amount" FROM "parent1"ORDER BY "parent1"."id" DESC LIMIT 1)
Answer the question
In order to leave comments, you need to log in
SELECT *
FROM (
SELECT "product_id", "amount"
FROM "parent1"
ORDER BY "parent1"."id" DESC
LIMIT 1
) t
UNION
SELECT "product_id", "amount"
FROM "child1"
WHERE "child1"."parent_id" = (SELECT "product_id" FROM "parent1"ORDER BY "parent1"."id" DESC LIMIT 1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question