Answers.Body: <p>Alternatively ...</p>
  <ol>
  <li>fire up api4 explorer and prepare your query. Make sure to ✔ the debug option</li>
  <li>execute the query</li>
  <li>click the 'Debug' tab next to the 'Result' tab</li>
  </ol>
  <p><a href="https://i.sstatic.net/6yBrV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6yBrV.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-25T16:25:02.100Z
Answers.Text: ooh, I don't see that on 5.36, perhaps it came later.
Answers.UserDisplayName: artfulrobot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-25T14:26:12.537Z
Answers.LastActivityDate: 2021-06-25T14:26:12.537Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>You can do this from the API explorer if you use your browser's dev tools.</p>
  <ol>
  <li>fire up api4 explorer and prepare your query. Make sure to ✔ the <strong>debug</strong> option, and un-✔ the check permissions box.</li>
  <li>open your browser's dev tools console</li>
  <li>execute the query</li>
  <li>inspect the network response JSON: at the top level (the same level as <code>values</code> you'll see a <code>debug</code> entry, which includes the SQL.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-25T13:39:29.497Z
Answers.LastActivityDate: 2021-06-25T13:39:29.497Z
Answers.UserDisplayName: artfulrobot
Answers.Body: <p>You can do this via code by adding <code>-&gt;setDebug(TRUE)</code> as a parametr to your call. Then, when you get the results (e.g. <code>$results</code>) examine <code>$results['debug']['sql'][0]</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-03T14:06:24.413Z
Answers.LastActivityDate: 2021-09-03T14:06:24.413Z
Answers.UserDisplayName: Jamie
Body: <p>When trying to express SQL joins with API4 I feel the need to check the SQL that's being created, as there's some 'magic' that might or might not be happening.</p>
  <p>It wasn't clear to me how to do this.</p>
  
Tags: <apiv4>
Title: How to see the SQL generated by Api4 calls?
ThreadText: # How to see the SQL generated by Api4 calls?
  
  (Asked by: username_0 on 2021-06-25)
  
  When trying to express SQL joins with API4 I feel the need to check the SQL that's being created, as there's some 'magic' that might or might not be happening.
  
  It wasn't clear to me how to do this.
  
  **Tags:** apiv4
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2021-06-25. Score: 4
  
  Alternatively ...
  
  1. fire up api4 explorer and prepare your query. Make sure to ✔ the debug option
  2. execute the query
  3. click the 'Debug' tab next to the 'Result' tab
  
  [![enter image description here](https://i.sstatic.net/6yBrV.png)](https://i.sstatic.net/6yBrV.png)
  
  > **Comments:**
  > **username_0**: ooh, I don't see that on 5.36, perhaps it came later.  
  
  ---
  
  ### Answer by username_0 on 2021-06-25. Score: 2
  
  You can do this from the API explorer if you use your browser's dev tools.
  
  1. fire up api4 explorer and prepare your query. Make sure to ✔ the **debug** option, and un-✔ the check permissions box.
  2. open your browser's dev tools console
  3. execute the query
  4. inspect the network response JSON: at the top level (the same level as `values` you'll see a `debug` entry, which includes the SQL.
  
  
  ---
  
  ### Answer by username_2 on 2021-09-03. Score: 1
  
  You can do this via code by adding `->setDebug(TRUE)` as a parametr to your call. Then, when you get the results (e.g. `$results`) examine `$results['debug']['sql'][0]`.
  
  
  ---
  
  