Postgres Join Error
Postgres Join Error
bcavalieri
Posts: 2Questions: 0Answers: 0
I'm getting the following error when trying to join 2 postgres tables:
[quote]Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax
LINE 6: pg_class.oid = 'sites as sites'::regclass AND[/quote]
When I look in the postgres logs I see:
[code]
SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
FROM pg_index, pg_class, pg_attribute
WHERE
pg_class.oid = 'sites as sites'::regclass AND
indrelid = pg_class.oid AND
pg_attribute.attrelid = pg_class.oid AND
pg_attribute.attnum = any(pg_index.indkey)
AND indisprimary;
[/code]
Far as I know you can't have an alias in the where statement with postgres. Any ideas howto keep the alias in the where from happening?
[quote]Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax
LINE 6: pg_class.oid = 'sites as sites'::regclass AND[/quote]
When I look in the postgres logs I see:
[code]
SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
FROM pg_index, pg_class, pg_attribute
WHERE
pg_class.oid = 'sites as sites'::regclass AND
indrelid = pg_class.oid AND
pg_attribute.attrelid = pg_class.oid AND
pg_attribute.attnum = any(pg_index.indkey)
AND indisprimary;
[/code]
Far as I know you can't have an alias in the where statement with postgres. Any ideas howto keep the alias in the where from happening?
This discussion has been closed.
Replies
[code]
// Set up the JOIN query
$stmt = $dte->db()
->query( 'select' )
->get( $pkeyTable.'.'.$joinField.' as _dte_pkey' )
->get( $this->_fields('get') )
->table( $dteTable );
//->table( $dteTable .' as '. $dteTableAlias );
[/code]
Allan