Expression matching related question

Started by Peter Hoskinabout 20 years ago4 messagesgeneral
Jump to latest
#1Peter Hoskin
peterh@criten.org

Hi,

I wish to do a query such as:
SELECT * FROM table WHERE column='something' AND column2='something
else' AND (network='0' OR (left=0 AND network>0));

However, when I execute this in phppgadmin I'm told there is an error
around the = character in left=0. Can't seem to figure the syntax.

Help would be appreciated.

Regards,
Peter Hoskin

#2Peter Hoskin
peterh@criten.org
In reply to: Peter Hoskin (#1)
Re: Expression matching related question

I should of mentioned, left is a bigint and network is an integer

Peter Hoskin wrote:

Show quoted text

Hi,

I wish to do a query such as:
SELECT * FROM table WHERE column='something' AND column2='something
else' AND (network='0' OR (left=0 AND network>0));

However, when I execute this in phppgadmin I'm told there is an error
around the = character in left=0. Can't seem to figure the syntax.

Help would be appreciated.

Regards,
Peter Hoskin

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#3Michael Fuhr
mike@fuhr.org
In reply to: Peter Hoskin (#1)
Re: Expression matching related question

On Mon, Apr 10, 2006 at 06:23:01AM +1000, Peter Hoskin wrote:

I wish to do a query such as:
SELECT * FROM table WHERE column='something' AND column2='something
else' AND (network='0' OR (left=0 AND network>0));

However, when I execute this in phppgadmin I'm told there is an error
around the = character in left=0. Can't seem to figure the syntax.

If you're using reserved words like table, column, and left as
identifiers then you'll need to double-quote them. Better yet,
avoid using reserved words as identifiers.

--
Michael Fuhr

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Hoskin (#1)
Re: Expression matching related question

Peter Hoskin <peterh@criten.org> writes:

I wish to do a query such as:
SELECT * FROM table WHERE column='something' AND column2='something
else' AND (network='0' OR (left=0 AND network>0));

However, when I execute this in phppgadmin I'm told there is an error
around the = character in left=0. Can't seem to figure the syntax.

LEFT is a reserved word, isn't it? If you're going to insist on naming
a column "left", you'll have to double-quote the name every time.

regards, tom lane