robertohuertasm / SQLite4Unity3d

SQLite made easy for Unity3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many to Many relationships

devotionsolutions opened this issue · comments

What's the proper way to deal with many to many relationships between tables using this library?
Let's say we have three tables:

  • Categories
  • SubCategories
  • Categories_SubCategories (including many to many relationships within the previous tables, referencing their PKs)

Like in this diagram

Any idea?

You always can use manual queries with this library.

Select * from categories right join categories_subcategoris on categories.id = categories_subcategories.categories_id left join sub_categories on categories_subcategories.subcategories_id = subcategories.id

You always can use manual queries with this library.

Select * from categories right join categories_subcategoris on categories.id = categories_subcategories.categories_id left join sub_categories on categories_subcategories.subcategories_id = subcategories.id

Great idea, but unfortunately "RIGHT and FULL OUTER JOINs are not currently supported" for sqlite

You could emulate RIGHT JOIN with LEFT JOIN by swapping the position table when selecting it.

Select * from categories_subcategoris left join categories on categories.id = categories_subcategories.categories_id left join sub_categories on categories_subcategories.subcategories_id = subcategories.id

Hope it help.

You could emulate RIGHT JOIN with LEFT JOIN by swapping the position table when selecting it.

Select * from categories_subcategoris left join categories on categories.id = categories_subcategories.categories_id left join sub_categories on categories_subcategories.subcategories_id = subcategories.id

Hope it help.

Thanks! it worked!