Title: SQL query for current user Report
Last modified: August 20, 2016

---

# SQL query for current user Report

 *  Resolved [SheriW7](https://wordpress.org/support/users/sheriw7/)
 * (@sheriw7)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/)
 * Hi Eli,
 * Thank you for the plugin. I do not know how to write SQL queries, and would like
   to use your plugin for producing some reports that are for the Current User’s
   activities on my site. I’m trying to produce a report that will show scores for
   quizzes that a user took.
 * Below is what I have so far which produced the saved report. It displays the 
   report on my page but shows the report as “empty.” Would you be able to write
   me the proper query to use? answered, correct, and quiz are the columns in a 
   table called ssquiz_users. I’d like to show this data for the Logged in user (
   just for the quizzes that they took). I appreciate any help you can provide.
 * SELECT answered, correct, quiz FROM ssquiz_users, wp_users WHERE user_name = ‘
   <?php $current_user->ID ?>’
 * [http://wordpress.org/extend/plugins/elisqlreports/](http://wordpress.org/extend/plugins/elisqlreports/)

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

 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585687)
 * Well you don’t need the wp_users table if ssquiz_users has a user_id field, and
   you should be using that user_id filed in you where not user_name.
 * So, maybe this will work:
    `SELECT answered, correct, quiz FROM ssquiz_users 
   WHERE user_id = <?php $current_user->ID ?>`
 *  Thread Starter [SheriW7](https://wordpress.org/support/users/sheriw7/)
 * (@sheriw7)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585731)
 * I tried that and received this error message: ERROR: Unknown column ‘user_id’
   in ‘where clause’ SQL:SELECT answered, correct, quiz FROM ssquiz_users WHERE 
   user_id = 1
 * Any other thoughts on how to pull this report? Thanks Eli, Sheri
 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585749)
 * ok, so there is no user_id in the ssquiz_users table, but there must be a field
   in that table that relates to the user that took the quiz. Find out what the 
   filed is called and use that.
 *  Thread Starter [SheriW7](https://wordpress.org/support/users/sheriw7/)
 * (@sheriw7)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585783)
 * I got this below to work. Thanks for your guidance. Your plugin is going to help
   me a great deal to display reports for each user – awesome!
 * SELECT answered, correct, quiz, date_stamp FROM ssquiz_users WHERE user_email
   = ‘<?php $current_user->user_email ?>’
 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585785)
 * Great! I’m glad you figured it out.
 * Don’t forget to donate if you can so that I can keep making improvements and 
   adding new features.
 * Aloha, Eli

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

The topic ‘SQL query for current user Report’ is closed to new replies.

 * ![](https://ps.w.org/elisqlreports/assets/icon-256x256.png?rev=1231385)
 * [EZ SQL Reports Shortcode Widget and DB Backup](https://wordpress.org/plugins/elisqlreports/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elisqlreports/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elisqlreports/)
 * [Active Topics](https://wordpress.org/support/plugin/elisqlreports/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elisqlreports/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elisqlreports/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Eli](https://wordpress.org/support/users/scheeeli/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/sql-query-for-current-user-report/#post-3585785)
 * Status: resolved