title: Mysql query : If value(s) exist(s) in column, select just the value(s), else select all
body: <p>Having a <code>Mysql</code> database, I have to select all <code>( TUser.Name, TAccount.Name )</code> pairs if <code>TUser.name</code> not exists in variable <code>@UserNames</code>.<br>
  If exists, I have to select only the <code>( TUser.Name, TAccount.Name )</code> pairs where <code>TUser.name</code> in <code>@UserNames</code>.  </p>
  
  <p>Something like the last line of the below query :</p>
  
  <pre><code>DECLARE @UserNames = "Alpha, Beta, Gama";
  
  SELECT User.Name
       , Account.Name
    FROM TUser
       , TAccount
       , TUserAccount
   WHERE TAccount.ID = TUserAccount.AccountID
     AND TUserAccount.UserID = User.ID
  -- please rewrite this line
     AND TUser.Name IN ( IFNULL ( ( SELECT ID FROM TUser WHERE Name IN @UserNames ) , ( SELECT ID FROM TUser ) ) )
  </code></pre>
  
  <p>Thank you in advance !</p>