title: 'No such Column' error when using SELECT on a view
body: <pre><code>CREATE VIEW [0_NumOfCode] AS
      SELECT tbDeviceId.deviceId,
             count(DISTINCT tbCodeList_AV.codeNum) AS NumCode
        FROM tbDeviceId
             INNER JOIN
             tbCodeList_AV ON tbDeviceId.deviceId = tbCodeList_AV.deviceId
       GROUP BY tbDeviceId.deviceID
      UNION
      SELECT tbDeviceId.deviceID,
             count(DISTINCT tbCodelist_AC.codeNum) 
        FROM tbDeviceId
             INNER JOIN
             tbCodelist_AC ON tbDeviceId.deviceId = tbCodelist_AC.deviceId
       GROUP BY tbDeviceId.DeviceID;
  </code></pre>
  
  <p>Context: I'm actually creating a C++ program that uses SQLite and takes in input of a .db file, so this SQL code that I've given here(which is from the db file) is not mine and I don't think I should (or should have to) change it, but I'm facing a perplexing problem, which is why I'm asking this question.</p>
  
  <p>Basically, now I want to SELECT the deviceId column of this 0_NumOfCode view, but how do I do that? 
  Neither</p>
  
  <pre><code>SELECT tbDeviceId.deviceId FROM [0_NumOfCode]
  </code></pre>
  
  <p>nor</p>
  
  <pre><code>SELECT deviceId FROM [0_NumofCode]
  </code></pre>
  
  <p>nor </p>
  
  <pre><code>SELECT [0_NumOfCode].deviceId FROM [0_NumOfCode]
  </code></pre>
  
  <p>did the job (The 'No such column' error). However, when I select *, the column and the data does show up under tbDeviceId.deviceID</p>
  
  <p>Now, I <em>THINK</em> an alias for the column might solve the problem, but like I said, I don't think I should change the SQL code. So </p>
  
  <p>1) Given this SQL code, how do I do this?</p>
  
  <p>2) (for my own curiosity) An alias would have solved it too, right?</p>
  
  <p><strong>UPDATE :</strong> My initial questions have been solved (in the comments), although I'm still kinda lost on how it works(' vs ` vs no quotes). </p>
  
  <p>Also, a new problem I face:</p>
  
  <pre><code>SELECT tbdeviceid.DeviceID,
         numcode,
         numbrand,
         devicename15,
         devicename30,
         comment,
         devicenameCN
    FROM tbdeviceid
         INNER JOIN
         [0_NumofBrand] ON tbdeviceid.deviceId = [0_NumofBrand].deviceId
         INNER JOIN
         [0_numofcode] ON tbdeviceid.deviceId = [0_numofcode].deviceId
  </code></pre>
  
  <p>The last line gives the no such column error. How do I represent the column?</p>