Title: Fetch data from 2 different tables
Last modified: August 30, 2016

---

# Fetch data from 2 different tables

 *  Resolved [RC2102](https://wordpress.org/support/users/rc2102/)
 * (@rc2102)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/fetch-data-from-2-different-tables/)
 * Many thanks for the brilliant plugin and i know that this is not an issue with
   the plugin but I’m trying to fetch data from 2 different tables. The following
   is the SQUERY I’m inputting:
 * SELECT * FROM `s2j_sabai_entity_field_directory_contact`
    `s2j_sabai_directory_claim`
   WHERE 1
 * Unfortunately The data comes up correctly for the first table but as for the 
   second table data is all identical. I’ve also tried using JOIN / UNION statement
   but returned no luck. Can someone help me please. Thank you.
 * [https://wordpress.org/plugins/exports-and-reports/](https://wordpress.org/plugins/exports-and-reports/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/fetch-data-from-2-different-tables/#post-6315647)
 * Try:
 *     ```
       SELECT * FROM s2j_sabai_entity_field_directory_contact AS contact
       LEFT JOIN s2j_sabai_directory_claim AS claim ON claim.contact = contact.id
       ```
   
 * I assume you have some connection there between the two tables, correct?
 * If both tables have the same field names, you may want to select them outright
   instead of using `*`.
 *  Thread Starter [RC2102](https://wordpress.org/support/users/rc2102/)
 * (@rc2102)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/fetch-data-from-2-different-tables/#post-6315649)
 * Thank you Scott… I have updated the code
 *     ```
       SELECT * FROM s2j_sabai_entity_field_directory_contact AS contact
       LEFT JOIN s2j_sabai_directory_claim AS claim ON claim.claim_entity_id = contact.entity_id
       ```
   
 * but returned one line with the correct details. There are 2 fields which are 
   similar but they don’t have the same name which are claim_entity_id and entity_id
 * The following are fields which I want to get data from which I have added in 
   the Fields (optional) section from the settings of the plugin:
    Claim Entity 
   Id > s2j_sabai_directory_claim Claim Name > s2j_sabai_directory_claim Claim Email
   > s2j_sabai_directory_claim Claim Entity Bundle Name > s2j_sabai_directory_claim
   Claim Status > s2j_sabai_directory_claim Mobile > s2j_sabai_entity_field_directory_contact
   Phone > s2j_sabai_entity_field_directory_contact Email > s2j_sabai_entity_field_directory_contact
   Website > s2j_sabai_entity_field_directory_contact Entity Id >s2j_sabai_entity_field_directory_contact
 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/fetch-data-from-2-different-tables/#post-6315660)
 * When adding the fields into Exports and Reports, put their field name such as“
   claim_name” and put as the “Real Name” the full path, such as “claim.claim_name”(
   alias must be included for the Real Name).
 * Let me know how that helps.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Fetch data from 2 different tables’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/exports-and-reports.svg)
 * [Exports and Reports](https://wordpress.org/plugins/exports-and-reports/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/exports-and-reports/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/exports-and-reports/)
 * [Active Topics](https://wordpress.org/support/plugin/exports-and-reports/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/exports-and-reports/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/exports-and-reports/reviews/)

## Tags

 * [tables](https://wordpress.org/support/topic-tag/tables/)

 * 3 replies
 * 2 participants
 * Last reply from: [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/fetch-data-from-2-different-tables/#post-6315660)
 * Status: resolved