D
D
dblearn942019-11-11 12:03:24
SQL
dblearn94, 2019-11-11 12:03:24

Get an entry, and if not, then the parent element?

Faced a problem, in sql I am weak.
there is such a structure:
page - id, title, parent_id
options - id, name
page_options - id, option_id, page_id, value should
work like this:
for the current id is not found, then we look at the parent of the current page and return the options for the parent.
How to implement something like this, without unnecessary checks in php and unnecessary requests, how would it be right?
Here is such a scheme:
5dc923d038099545472686.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question