1

I've built an accessory to allow my client to export channel entry data to a CSV. All is working fine but they now want to add the entry status to the list of exported fields and I'm having trouble with the SQL. My select statement as it stands:

SELECT
field_id_49 as 'First Name',
field_id_50 as 'Last Name',
field_id_51 as 'Email',
field_id_56 as 'Date of Birth',
field_id_53 as 'Occupation',
field_id_52 as 'Gender',
field_id_57 as 'Address',
field_id_58 as 'Address 2',
field_id_59 as 'City',
field_id_60 as 'Postal Code',
field_id_54 as 'Contact Number',
field_id_55 as 'First Aid Qualification',
field_id_61 as 'Payment Choice'
FROM exp_channel_data 
WHERE channel_id = 13

I know I need to get the status from exp.channel.titles but I'm not sure how to join it all together. I just need to return a status no matter what it is.

Can any point me in the right direction?

Cheers

4

This should cover it.

SELECT
    field_id_49 as 'First Name',
    field_id_50 as 'Last Name',
    field_id_51 as 'Email',
    field_id_56 as 'Date of Birth',
    field_id_53 as 'Occupation',
    field_id_52 as 'Gender',
    field_id_57 as 'Address',
    field_id_58 as 'Address 2',
    field_id_59 as 'City',
    field_id_60 as 'Postal Code',
    field_id_54 as 'Contact Number',
    field_id_55 as 'First Aid Qualification',
    field_id_61 as 'Payment Choice',
    status as 'Status'
FROM exp_channel_data as data
LEFT JOIN exp_channel_titles as titles
ON data.entry_id = titles.entry_id
WHERE data.channel_id = 13
| improve this answer | |
  • Thanks Jeremy - I just had to add the 'data.' prefix to channel_id = 13 and all works great :) – xenowebdev Oct 30 '13 at 22:08
  • 1
    Yep, I had it when I was testing but had to merge my test with your field_ids and missed that one. Edited above for future people. – Jeremy Worboys Oct 30 '13 at 22:10

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.