Re: How to query by column names

From: Jeff Frost <jeff(at)frostconsultingllc(dot)com>
To: Richard Ray <rray(at)mstc(dot)state(dot)ms(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to query by column names
Date: 2007-01-23 01:32:28
Message-ID: Pine.LNX.4.64.0701221727430.5992@discord.home.frostconsultingllc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 22 Jan 2007, Richard Ray wrote:

> On Mon, 22 Jan 2007, Jeff Frost wrote:
>
>> So why are you avoiding "SELECT * FROM t1;" ?
>>
> I was affeared that if I brought my total ignorance to light I would be band
> from the list but here goes.
> I work in UNIX/Linux environments.
> It's my habit to record my scripts.
> A simple example:
>
> #!/bin/bash
> CMD="psql -d test \"select * from t1\""
> echo $CMD >> my_log
> eval $CMD |
> while read x; do
> do_something_with_x
> done
>
> In this example * expands to all files in the current working directory.
> I was attempting to get around this by enumerating the table attributes.

Oh! Why didn't you just say that in the first place. You just need quotes.
Try this:

psql -c 'select * from t1' test

or

psql -c "select * from t1" test

or

echo "select * from t1" | psql test

--
Jeff Frost, Owner <jeff(at)frostconsultingllc(dot)com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Williams 2007-01-23 05:03:38 Re: How to query by column names
Previous Message Richard Ray 2007-01-23 01:25:22 Re: How to query by column names