Title: SQL structure
Last modified: August 30, 2016

---

# SQL structure

 *  Resolved [Dave3o3](https://wordpress.org/support/users/dave3o3/)
 * (@dave3o3)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-structure/)
 * Hi,
 * could you please provide a code snipped or could tell me how i can save the kvk-
   number and other meta data in the related company database?
 * currently i only find these data in the postmeta database.
 * Thank you!
 * [https://wordpress.org/plugins/orbis/](https://wordpress.org/plugins/orbis/)

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

 *  [Reüel](https://wordpress.org/support/users/pronamic_reuel/)
 * (@pronamic_reuel)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-structure/#post-6456854)
 * I don’t think I fully understand your question, what exactly do you mean by “
   related company database” or what are you trying to accomplish?
 * The meta data is indeed saved as post meta, and thus can be found in the _wp\
   _postmeta_ database table.
 * To get the post meta for a given company post ID in your theme:
    `<?php $meta
   = get_post_meta( [the company post ID ] ); ?>`
 * To get the Orbis post meta for a given company post ID in plain SQL:
    `SELECT*
   FROM wp_postmeta WHERE post_id=[the company post ID] AND meta_key LIKE '_orbis_%'`
 * To get the Orbis post meta for a given Orbis ID (as mentioned in the WordPress
   dashboard) in plain SQL:
    `SELECT m.* FROM wp_postmeta AS m LEFT JOIN wp_postmeta
   AS orbis ON m.post_id=orbis.post_id WHERE orbis.meta_key='_orbis_company_id' 
   AND m.meta_key LIKE '_orbis_%' AND orbis.meta_value=[the Orbis ID]`
 *  Thread Starter [Dave3o3](https://wordpress.org/support/users/dave3o3/)
 * (@dave3o3)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-structure/#post-6456857)
 * Hi,
 * thanks for replying.
 * No, thats actually the way to GET or READ the linked meta data.
    But i’m looking
   for a way to WRITE the meta data like kvk-number or address into the company 
   table. Actually the name, the orbis ID and the e-mail are written into the table
   wp_orbis_companies. I want the other fields also to be written into that table;
   linked to the orbis ID.
 *  Plugin Author [Remco Tolsma](https://wordpress.org/support/users/remcotolsma/)
 * (@remcotolsma)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-structure/#post-6456861)
 * Why do you want to store the KVK-number in the companies table? We have plans
   to narrow down the custom companies table. Currently only the company name is
   synced to the companies table. You can find the related code here: [https://github.com/wp-orbis/wp-orbis/blob/1.3.2/includes/companies.php#L105-L134](https://github.com/wp-orbis/wp-orbis/blob/1.3.2/includes/companies.php#L105-L134).

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

The topic ‘SQL structure’ is closed to new replies.

 * ![](https://ps.w.org/orbis/assets/icon.svg?rev=1022915)
 * [Orbis](https://wordpress.org/plugins/orbis/)
 * [Support Threads](https://wordpress.org/support/plugin/orbis/)
 * [Active Topics](https://wordpress.org/support/plugin/orbis/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/orbis/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/orbis/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 3 replies
 * 3 participants
 * Last reply from: [Remco Tolsma](https://wordpress.org/support/users/remcotolsma/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/sql-structure/#post-6456861)
 * Status: resolved