Thread: Looking for help
I am new to combining PHP and Postgres. I am able to Select and create tables by using the Select * From "table" command fine, but What happens if I only want to select a couple of fields. How do I go about this. also how do you select from a table that is not all lower case. Granted this is probably quite simple, but I am new to this. thanks ewveryone -- Joseph L Montes Senior Systems Engineer Zenplex Inc. 317 Madison Ave. suite 1500 New York New York V(212)499-0668 Ext. 203 F(646)865-0783 http://www.zenplex.com http://www.zenplex.org http://www.tambora.org
Use quotes around the field and table names that are not all lower case: Ex: $result = pg_query($db," Select 'Field1',field2, 'fEild3' From'TABLE1' "); Patrick Hatcher Joseph L Montes <jmontes@zenplex.com To: pgsql-php@postgresql.org > cc: Sent by: Subject: [PHP] Looking for help pgsql-php-owner@post gresql.org 08/27/2002 03:56 PM I am new to combining PHP and Postgres. I am able to Select and create tables by using the Select * From "table" command fine, but What happens if I only want to select a couple of fields. How do I go about this. also how do you select from a table that is not all lower case. Granted this is probably quite simple, but I am new to this. thanks ewveryone -- Joseph L Montes Senior Systems Engineer Zenplex Inc. 317 Madison Ave. suite 1500 New York New York V(212)499-0668 Ext. 203 F(646)865-0783 http://www.zenplex.com http://www.zenplex.org http://www.tambora.org ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Hi Joseph > but What happens > if I only want to select a couple of fields. Then you tell the server which fields you want to select;-) SELECT field1, field2, ... , fieldn FROM table ... > how do you select from a table that is not all lower case what do you mean? what is not all lower case? PostgreSQL returns the contents of the fields as they are. If you need the results to be in lower case use SELECT lower(fieldx), lower(field2),... FROM table respectively SELECT upper(field1), upper(field2), ... FROM table. See chapter 4.4 of the PostgreSQL user's Guide for more. The PHP-Functions to change case are strtoupper() and strtolower(). Hope it helps Regards Conni
2002. augusztus 28. 01:05 dátummal Patrick Hatcher ezt írta: > Use quotes around the field and table names that are not all lower > case: > > Ex: > $result = pg_query($db," Select 'Field1',field2, 'fEild3' > From'TABLE1' "); > AFAIK, opstgres needs double quotes to handle objects' names literally -- as written: $result = pg_query($db,' Select "Field1",field2, "fiEld3" From "TABLE1"'); text within simple quotes represents string literals. -- Papp, Győző - pgerzson@freestart.hu
on 8/27/02 4:56 PM, jmontes@zenplex.com purportedly said: > also how do you select from a table that is not all lower case. Granted > this is probably quite simple, but I am new to this. thanks ewveryone Table and column names are not case-sensitive in Postgres. Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet"