I am trying to effectively get data in my project. I have database (multilanguage). And I need to get all toplevel categories (which has no parent_id in top level) and those which has no record in data table (deepest) in single_article.
category_meta is toplevel, version has foreign key meta_id from meta id, category table has foreign key from version table in version_id.
I can do it in multiple queries. First get IDs for toplevel, then get top IDs without single set on, then diff .. but I hope there is better way I cannot see.
Tables has sequel associations on these IDs. meta to version one_to_many-many_to_many and one_to_one between version and "data" the category table
Any suggestions please?
If you have an idea just in sql it will be helpful too
Thanks
M.
I need to get ID from category_meta and category column from category, paired.
in SQL it would look like this:
select category_meta.id, category.category
from category_meta
join category_version using(category_meta.id = category_version.meta_id)
join category using(category.version_id = category_version.id)
where category_meta.type = 'some_type';
You didn't specify any where conditions so I just kind of through one in there as a guess.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.