Passer la navigation

[Résolu] SQL Query to get content from 2 custom post type with a relationship.

This support ticket is created Il y a 4 years, 3 months. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Fuseau horaire du supporter : Asia/Kolkata (GMT+05:30)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par Minesh Il y a 4 years, 3 months.

Assisté par: Minesh.

Auteur
Publications
#2276565
Relationship.JPG

I'd like to write a SQL query to extract content from 2 custom post types(Chapters and Members) that have a relationship

Chapters and Members
1 chapter can be assigned to one member
infinite members can be assigned to one chapter

I've looked at the various tables but I'm not able to determine which tables contain the relationship info to do the necessary Join in my SQL statement. Would you please provide some insight or additional documentation on how to accomplish my SQL Query

#2277363

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

We offer post relationship API function to get related posts:
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

In addition to that if you want to use core WP_Query, please check the following Doc:
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#wp_query-argument-for-querying-by-related-posts

Please let me know if that helps.

#2277711

While this information is helpful, it doesn't solve my problem. do you have schema documentation on the database tables you are using for relationships? I'm not using php or your api, I'm writing SQL.

#2278347

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Please check the following screenshot for schema: lien caché

The relationship with content is stored using the following database tables:
- {db-prefix}_toolset_connected_elements
- {db-prefix}_toolset_relationships
- {db-prefix}_toolset_associations
- {db-prefix}_toolset_type_sets
- {db-prefix}_posts

I hope this helps.