When working in the Views module, you may want to preview the SQL that is generated by the view. This is for the code savvy or the ones looking to be and would like to see the SQL generated for either debugging or further development of their views. Sometimes seeing the code can help understand how the view works in case it needs further tweaking. Showing the SQL query for a View's preview is done with the following instructions.

Showing the SQL query for a view preview in Drupal 7 Views

  1. Log into your Drupal 7 admin dashboard.
  2. From the top menu bar, locate the Structure option and click it.
    structure
  3. Click on the Views option to move to the next screen.
    structure-views
  4. You are now on the Views list screen. Look to the upper right and you will see two tabs. Click on the one that is labeled Settings.
    view-settings
  5. Once you get to the Settings page scroll down to the bottom of the screen to the Live Preview Settings and find the checkbox labeled Show the SQL query. Click the checkbox to enable the feature.
    set-query-preview
  6. Once finished, click on the Save Configuration button at the bottom. Preview one of your views and you will now see the SQL code.
    show-query-after
Continued Education in Course 211: Views Module Tutorial
You are viewing Section 8: Displaying the SQL query for a view when previewing in Drupal 7 Views
Section 7: How to disable caching in Drupal 7 Views module
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

n/a Points
2014-03-31 9:29 pm

That still only shows a partial query...

Staff
10,022 Points
2014-04-01 8:38 am
This shows the full MySQL query that is being executed to generate the information displayed. Could you clarify what additional information you are looking for?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

2 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!