Title: SQL in DB Connection
Last modified: March 23, 2020

---

# SQL in DB Connection

 *  Resolved [nici-](https://wordpress.org/support/users/nici-2/)
 * (@nici-2)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/sql-in-db-connection/)
 * Hiho,
 * I need to connect data that I will store in a seperate table in the WordPress
   database. This is data which shows “monthly counts”. So every month there will
   be a new row added with the count data from the latest month.
    For example:
 *  bikes | cars | pedestrian
    202001 3 | 18 | 201 202002 4 | 20 | 99
 * With every month getting a new row added.
 * I found out that I can connect a database when using the developer version. So
   far so good.
 * My question is: To always have the “latest row” adressed (or the three latest,
   whatever), I cannot connect to a “given” table row. I would need to adress the
   data through SQL like SORT plus LIMIT. I want to show the data through calculated
   fields in sorted tables/overviews an perhaps also do some calculations.
 * Question: Is this possible or how would a solution for this problem would look
   like?
 * Thanks for your input.
 * Best regards,
    nici-

Viewing 1 replies (of 1 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/sql-in-db-connection/#post-12575494)
 * Hello [@nici-2](https://wordpress.org/support/users/nici-2/)
 * Yes of course, that’s possible, you can tick the “Custom query” attribute in 
   the DS fields for entering a custom query. For example, assuming your table’s
   name is: my_table, and you want the newest three rows, sorted by the “month” 
   column, and you are using a Recordset DS field. In the case of RecordSet DS field
   you don’t need to tick the “Custom query” option, because the queries must be
   entered directly. Insert the RecordSet DS field in the form, and enter the query
   as follows:
 *     ```
       SELECT * FROM my_table ORDER BY month DESC LIMIT 3
       ```
   
 * For additional questions about the commercial features of the plugin, you should
   contact us through our private website: [Contact Us](https://cff.dwbooster.com/contact-us)
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘SQL in DB Connection’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [limit](https://wordpress.org/support/topic-tag/limit/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/sql-in-db-connection/#post-12575494)
 * Status: resolved