title: How to select columns in Hive SQL with the same prefix (beginning) or suffix (ending) or key word in the middle (including)
body: <p>EDIT 1: Note, I know some of us will question why not list different parts of information in different attributes, so that I will have a relational database to query. The real case is not like the example I am listing below, the variable names are just used here for convenience. </p>
  
  <p>EDIT 2: To reduce the confusion of database design, I change the variable names in the example.</p>
  
  <p>In Hive query, I am looking for a way to select columns with the same prefix, or the same suffix, or including the same key word in the middle of the variable names from the same table.</p>
  
  <p>Here is an example: I have a list of variables like this:</p>
  
  <pre><code>a_A_1, a_A_2, a_B_1, a_B_2,
  b_A_1, b_A_2, b_B_1, b_B_2
  </code></pre>
  
  <p><strong>Exercise 1</strong>
  I want to select all the attributes <em>starting with 'a'</em>.</p>
  
  <p><strong>Exercise 2</strong>
  I want to select all the attributes <em>ending with '1'</em>.</p>
  
  <p><strong>Exercise 3</strong>
  I want to select all the attributes <em>including 'B'</em>.</p>
  
  <p>Much thanks in advance!</p>