title: create a view with query result used in another query that need dynamic parameters
body: <p>This is the query and I use sails.js to replace ? with int:</p>
  
  <pre><code>SELECT * FROM user WHERE user.id IN 
  (SELECT DISTINCT message.from AS UserID FROM message WHERE message.from = ? or message.to = ? UNION SELECT message.to FROM message)
  group by user.id
  </code></pre>
  
  <p>my search lead me to this stackoverflow page
  <a href="https://stackoverflow.com/questions/19946526/how-pass-dynamic-parameter-in-mysql-view">how pass dynamic parameter in mysql view</a>
  the problem is I couldn't do it, if I replaced ? with user.id and create alias calling it userID, it doesn't get passed or saved as the answer says.
  I get error in Sql that userId doesn't exist.</p>