2

I need to write a custom query against the exp_channel_data table. However, one of the channel's field is a relationship field. How do I track that back to the appropriate column in the exp_channel_data?

I've looked in the exp_channel_fields table and found the relationship's field_id (say it's 10). However, when I look exp_channel_data.field_id_10, I just see some number in it. I was hoping it would give me the entry id of the row it's related to. Any ideas how to do this? I'm trying to do a JOIN based on the entry id.

2

The number that you are seeing in field_id is the rel_id from the exp_relationships table in that table you have access to the child and parent id's so that you can build your query.

| improve this answer | |
1

I would do something like this:

SELECT * 
FROM exp_channel_data 
INNER JOIN 
exp_channel_titles 
ON 
exp_channel_title.entry_id = exp:channel_data.entry_id

To get the join right for the two main tables, but what kind of information do you need exactly from the relationship field?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.