pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Equivalent for an Access query
4+ messages / 3 participants
[nested] [flat]

* Equivalent for an Access query
@ 1999-01-27 16:58  Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>
  0 siblings, 2 replies; 4+ messages in thread

From: jpmarichal@infoacces.com @ 1999-01-27 16:58 UTC (permalink / raw)
  To: pgsql-sql

I'm building a system to a contest. I have three tables: participantes (partakers), ordenes (orders) and productos (products). Partakers on the contest introduce their id in an HTML form, then this calls a PHP to query the database and return data taken from the three tables.

Using Microsoft Access, I get the SQL code for the query, then I copy it and paste it in my PHP code:

$result=pg_Exec($conn,"SELECT participantes.idven, participantes.nombreven, participantes.iding, participantes.nombreing, participantes.empresa, ordenes.num_ordenuf, ordenes.factura_spasp, ordenes.factura_vad, ordenes.fecha, ordenes.num_producto, productos.descripcion, ordenes.mayorista, productos.puntos, ordenes.cantidad, [puntos]*[cantidad] AS Total FROM productos INNER JOIN (participantes INNER JOIN ordenes ON idven = participante) ON idproducto = num_producto WHERE (((idven)="VHA1901081"))");

But Postgress don't accept the . operator, so it drops to me those nasty 'parse' error messages. I don't know if it's only due to the . operator, or the use of upper case or what. How must I build the SQL query to be accepted by Postgress and PHP? I'm drowning on it!



______________________
Brotherly,
JPMarichal
jpmarichal@infoacces.com
ICQ# 17246887



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Equivalent for an Access query
@ 1999-01-27 18:04  David Hartwig <daveh@insightdist.com>
  parent: Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>
  1 sibling, 0 replies; 4+ messages in thread

From: David Hartwig @ 1999-01-27 18:04 UTC (permalink / raw)
  To: jpmarichal@infoacces.com; +Cc: pgsql-sql



Juan Pablo Marichal Catalan wrote:

> I'm building a system to a contest. I have three tables: participantes (partakers), ordenes (orders) and productos (products). Partakers on the contest introduce their id in an HTML form, then this calls a PHP to query the database and return data taken from the three tables.
>
> Using Microsoft Access, I get the SQL code for the query, then I copy it and paste it in my PHP code:
>
> $result=pg_Exec($conn,"SELECT participantes.idven, participantes.nombreven, participantes.iding, participantes.nombreing, participantes.empresa, ordenes.num_ordenuf, ordenes.factura_spasp, ordenes.factura_vad, ordenes.fecha, ordenes.num_producto, productos.descripcion, ordenes.mayorista, productos.puntos, ordenes.cantidad, [puntos]*[cantidad] AS Total FROM productos INNER JOIN (participantes INNER JOIN ordenes ON idven = participante) ON idproducto = num_producto WHERE (((idven)="VHA1901081"))");
>
> But Postgress don't accept the . operator, so it drops to me those nasty 'parse' error messages. I don't know if it's only due to the . operator, or the use of upper case or what. How must I build the SQL query to be accepted by Postgress and PHP? I'm drowning on it!
>

This generally is not a good idea.    There are several syntax structures here which will give PostgreSQL trouble.   Such as:
    INNER JOIN  - syntax not supported yet
    [puntos]*[cantidad] -  PostgreSQL uses double quote as identified delimiters.

If you wish to continue down this path let me suggest a few items.

1.  set the query property to "snapshot"
2.  activate the CommLog in the driver.
3.  cut your statements out of the CommLog.

The MS Jet and the ODBC driver, PostgreSQL'ify them before they get to the server.

Hope this helps.










^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Equivalent for an Access query
@ 1999-01-28 07:31  Remigiusz Sokolowski <rems@gdansk.sprint.pl>
  parent: Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Remigiusz Sokolowski @ 1999-01-28 07:31 UTC (permalink / raw)
  To: Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>; +Cc: pgsql-sql


> $result=pg_Exec($conn,"SELECT participantes.idven,
> participantes.nombreven, participantes.iding, participantes.nombreing,
> participantes.empresa, ordenes.num_ordenuf, ordenes.factura_spasp,
> ordenes.factura_vad, ordenes.fecha, ordenes.num_producto,
> productos.descripcion, ordenes.mayorista, productos.puntos,
> ordenes.cantidad, [puntos]*[cantidad] AS Total FROM productos INNER
> JOIN (participantes INNER JOIN ordenes ON idven = participante) ON
> idproducto = num_producto WHERE (((idven)="VHA1901081"))");

should be

SELECT p1.idven, ......, o1.num_ordenuf, ........, p2.puntos, .....,
(p2.puntos*o1.cantidad) AS Total FROM
productos p2, ordenes o1, participantes p1 WHERE
p1.idven=o1.participante AND p1.idproducto=p2.num_producto AND
p1.idven='VHA1901081';

I could mistake at some fields, but syntax is ok.
	Rem

-------------------------------------------------------------------*------------
Remigiusz Sokolowski      e-mail: rems@gdansk.sprint.pl           * *		
-----------------------------------------------------------------*****----------




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Equivalent for an Access query
@ 1999-01-29 23:06  Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>
  parent: Remigiusz Sokolowski <rems@gdansk.sprint.pl>
  0 siblings, 0 replies; 4+ messages in thread

From: jpmarichal@infoacces.com @ 1999-01-29 23:06 UTC (permalink / raw)
  To: pgsql-sql


It works. Thanks a lot, Sokolowski.


*********** REPLY SEPARATOR ***********

On 28/01/99, at 8:31 AM, Remigiusz Sokolowski wrote: 

>> $result=pg_Exec($conn,"SELECT participantes.idven,
>> participantes.nombreven, participantes.iding, participantes.nombreing,
>> participantes.empresa, ordenes.num_ordenuf, ordenes.factura_spasp,
>> ordenes.factura_vad, ordenes.fecha, ordenes.num_producto,
>> productos.descripcion, ordenes.mayorista, productos.puntos,
>> ordenes.cantidad, [puntos]*[cantidad] AS Total FROM productos INNER
>> JOIN (participantes INNER JOIN ordenes ON idven = participante) ON
>> idproducto = num_producto WHERE (((idven)="VHA1901081"))");
>
>should be
>
>SELECT p1.idven, ......, o1.num_ordenuf, ........, p2.puntos, .....,
>(p2.puntos*o1.cantidad) AS Total FROM
>productos p2, ordenes o1, participantes p1 WHERE
>p1.idven=o1.participante AND p1.idproducto=p2.num_producto AND
>p1.idven='VHA1901081';
>
>I could mistake at some fields, but syntax is ok.
>	Rem
>
>-------------------------------------------------------------------*------------
>Remigiusz Sokolowski      e-mail: rems@gdansk.sprint.pl           * *		
>-----------------------------------------------------------------*****----------

______________________
Brotherly,
JPMarichal
jpmarichal@infoacces.com
ICQ# 17246887



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-01-29 23:06 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-01-27 16:58 Equivalent for an Access query Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>
1999-01-27 18:04 ` David Hartwig <daveh@insightdist.com>
1999-01-28 07:31 ` Remigiusz Sokolowski <rems@gdansk.sprint.pl>
1999-01-29 23:06   ` Juan Pablo Marichal Catalan <jpmarichal@infoacces.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox