title: MYSQL & Shell Scripting: Reference individual row attributes from table results?
body: <p>I am writing a shell script that outputs selected MySql table data as an exercise. Searches using my key words turn up only how to print out an entire MySql table, doing this in a different language and irrelevant questions.</p>
  
  <p>My questions: </p>
  
  <p>1) If possible, how do I reference individual attributes of a certain row from the results (like iterating when through rows with PHP results)?</p>
  
  <p>2) Which of the two ways below, if either, makes the most sense for this purpose? Neither works quite the way I would like at the moment.</p>
  
  <hr>
  
  <pre><code>MYSQL="mysql -u$db_user -p$db_passwd $db_name -Nbe"
  </code></pre>
  
  <p>A)</p>
  
  <pre><code>RESULT=`$MYSQL "select * from $table_name where can_auto_check='yes';"`
  for UNIQUEID in $RESULT
  do
      echo "selected: $client $desc "
      someFunction $client $anothervariable
  done
  </code></pre>
  
  <p>B)</p>
  
  <pre><code>$MYSQL "select * from $table_name where can_auto_check='yes';" \
  | while read client anothervariable;
  do
      echo "selected: $client $desc "
      someFunction $client $anothervariable
  done
  </code></pre>
  
  <hr>
  
  <p>It is possible I am wording my searches incorrectly; if that is the case, I would appreciate if someone would nudge me in the right direction. </p>
  
  <p>Thank you.</p>
  
  <p>EDIT: possible lead.. something to do with  awk '{print $1" "$2 }' maybe. but for every line.</p>
  
  <p>Final format = " mkdir -p /net/$SERVER/$CLIENT/$DESC/someFiles "</p>