using querys like: 'select table.*'

Started by eroblesover 16 years ago4 messagesgeneral
Jump to latest
#1erobles
erobles@sensacd.com.mx

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Droid Sans">Hi!<br>
<br>
In&nbsp; postgresql 7.2&nbsp; i can use&nbsp; this kind of querys:<br>
<br>
select&nbsp; table.* ; <br>
<br>
select&nbsp; * from&nbsp; table1 where&nbsp; table1.key=othertable.key;<br>
<br>
<br>
but in&nbsp; postgresql 8.3&nbsp; i have&nbsp; an error like this:<br>
ERROR: missing FROM-clause entry for table ...<br>
<br>
<br>
what should i do to solve this?&nbsp; :-)<br>
<br>
<br>
<br>
<br>
<br>
</font>
</body>
</html>

#2erobles
erobles@sensacd.com.mx
In reply to: erobles (#1)
Re: using querys like: 'select table.*'

erobles wrote:

Show quoted text

Hi!

In postgresql 7.2 i can use this kind of querys:

select table.* ;

select * from table1 where table1.key=othertable.key;

but in postgresql 8.3 i have an error like this:
ERROR: missing FROM-clause entry for table ...

what should i do to solve this? :-)

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: erobles (#2)
Re: using querys like: 'select table.*'

On Wednesday 02 December 2009 4:04:47 pm erobles wrote:

erobles wrote:

Hi!

In postgresql 7.2 i can use this kind of querys:

select table.* ;

select * from table1 where table1.key=othertable.key;

but in postgresql 8.3 i have an error like this:
ERROR: missing FROM-clause entry for table ...

what should i do to solve this? :-)

Short term see here for config setting in postgresql.conf that can revert the
behavior.
http://www.postgresql.org/docs/8.3/interactive/runtime-config-compatible.html#RUNTIME-CONFIG-COMPATIBLE-VERSION

Long term, change the queries :)

--
Adrian Klaver
aklaver@comcast.net

#4Craig Ringer
craig@2ndquadrant.com
In reply to: erobles (#1)
Re: using querys like: 'select table.*'

On 3/12/2009 7:58 AM, erobles wrote:

Hi!

In postgresql 7.2 i can use this kind of querys:

select table.* ;

select * from table1 where table1.key=othertable.key;

but in postgresql 8.3 i have an error like this:
ERROR: missing FROM-clause entry for table ...

what should i do to solve this? :-)

You've already been pointed to the workaround backward-compat option.

What's happening here is that you're doing an implicit inner join. Your
query is being interpreted by PostgreSQL as if you wrote:

select * from table1, othertable where table1.key=othertable.key;

though I prefer to write it as the IMO more readable:

select * from table1 INNER JOIN othertable ON table1.key=othertable.key;

This behaviour isn't supported anymore partly is because it's way too
easy to write:

select * from table1 where table1.key=typotable.key;

and get confusing error messages or, if `typotable' exists, confusing
query results. I'm pretty sure there were more reasons too, but I wasn't
really active on the lists when that was going on.

It's also really confusing when reading a query.

So - as already pointed out, you will need to re-write your queries to
add the required tables to the from clause.

--
Craig Ringer