title: MySQL column error on inner join
body: <p>I'm following a <a href="http://jugojava.blogspot.com/2011/02/jdbc-security-realm-with-glassfish-and.html" rel="nofollow noreferrer">tutorial</a>, and want to create a user role view.  This is the first thing I've ever done with SQL, though I know some of the basics.  I'm using the MySQL Workbench.</p>
  
  <p>My statement is like this:</p>
  
  <pre><code>CREATE VIEW `v_user_role` AS
  
  SELECT  u.Username, u.Password, g.name
  
   FROM `users_groups` ug
  
   INNER JOIN `user_table` u ON u.iduser = ug.userid
  
   INNER JOIN `group` g ON g.idgroup =  ug.groupid;
  </code></pre>
  
  <p>And the error I'm getting is:</p>
  
  <pre><code>ERROR 1054: Unknown column 'ug.userid' in 'on clause'
  </code></pre>
  
  <p>There's a foreign key in the users_groups table with the name userid.  What am I doing wrong?</p>
  
  <p>UPDATE: Describe for users_groups which just shows the id and not the foreign keys.  The select query mentioned below fails.</p>
  
  <p><img src="https://i.stack.imgur.com/FHmL0.png" alt="enter image description here"></p>