List:General Discussion« Previous MessageNext Message »
From:Mark Phillips Date:January 12 2006 6:09pm
Subject:Re: Question regarding running 'mysql' from a bash script
View as plain text  
Oops - I forgot my version of mysql - 4.0.22 running on Red Hat Linux 7.3 
2.96-113 kernel 2.4.20-30.7.

Mark

On Thursday 12 January 2006 10:43 am, Mark Phillips wrote:
> There is a column in my table with string values, but the strings have 
spaces 
> in them. I want to read the unique column values into an array in my bash 
> script, so I can use these values in a separate query on this table. How do 
I 
> get the values into an array?
> 
> For example, the column teams in my table
> 
> | team |.....
> Red Sox
> Chicago Colleens
> Athletics
> Kenosha Comets
> Red Sox
> 
> and I want to create the equivalent statement, but using what I find in the 
> table"
> 
> declare -a TEAMS=("Red Sox" "Chicago Colleens" "Athletics" "Kenosha Comets")
> 
> I tried the following:
> declare -a TEAMS=(`mysql -u "$USER" -h "$HOST" --password="$PASSWORD" -D 
> "$DATABASE" -B --disable-column-names --exec "select distinct team from 
> registered order by team"`)
> 
> but I get the following array (using the data above)
> 
> ("Red" "Sox" "Chicago" "Colleens" "Athletics" "Kenosha" "Comets")
> 
> How do I either (1) add quotes around each row entry returned so I get the 
> right array, or (2) fill the array in a different way?
> 
> Thanks!
> 
> -- 
> Mark Phillips
> Phillips Marketing, Inc
> mark@stripped
> 602 524-0376
> 480 945-9197 fax
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
http://lists.mysql.com/mysql?unsub=1
> 
> 

-- 
Mark Phillips
Phillips Marketing, Inc
mark@stripped
602 524-0376
480 945-9197 fax
Thread
Question regarding running 'mysql' from a bash scriptMark Phillips12 Jan
  • Re: Question regarding running 'mysql' from a bash scriptMark Phillips12 Jan
  • Re: Question regarding running 'mysql' from a bash scriptSid Lane12 Jan
    • Query optimizationTripp Bishop12 Jan
      • Re: Query optimizationJames Harvard12 Jan
        • Re: Query optimizationTripp Bishop12 Jan
          • Re: Query optimizationJoerg Bruehe13 Jan
          • innodb selectGeorge Law13 Jan
            • Re: innodb selectGleb Paharenko13 Jan
  • Re: Question regarding running 'mysql' from a bash scriptJake Peavy12 Jan
    • Re: Question regarding running 'mysql' from a bash scriptMark Phillips13 Jan
RE: Question regarding running 'mysql' from a bash scriptGeorge Law12 Jan
  • Re: Question regarding running 'mysql' from a bash scriptMark Phillips13 Jan