Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id A1A1E4764AB for ; Mon, 17 Jun 2002 18:17:01 -0400 (EDT) Received: from leo.pcisys.net (leo.pcisys.net [207.76.102.240]) by postgresql.org (Postfix) with ESMTP id 73F5E476254 for ; Mon, 17 Jun 2002 18:08:18 -0400 (EDT) Received: from [208.202.106.211] (moe1.meg106-211.cos.pcisys.net [208.202.106.211]) by leo.pcisys.net (8.12.1/8.12.1) via ESMTP id g5HM8E7G010429 for ; Mon, 17 Jun 2002 16:08:17 -0600 (MDT) env-from (hierophant@pcisys.net) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.4 Date: Mon, 17 Jun 2002 16:08:13 -0600 Subject: Re: results from a opinion form From: Keary Suska To: Postgres-PHP Message-ID: In-Reply-To: <3D05397800021FCD@nplex.globo.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Archive-Number: 200206/29 X-Sequence-Number: 1282 on 6/17/02 12:26 PM, angelo.rigo@globo.com purportedly said: > I am working on a web form for, where i have 12 fields asking to enumerate > to 5 to 1 to avaliate the weigth that feature have to people choose my > company. > I have choosed the data type to be a smallint on postgresql and a input > type text on html (php). > > And still i have 5 fields to indicate wich media the people have contact > and helps or not wich i decide to be char on postgresql and input type > checkbox > on php where true is 1. > > How can i count take statistics and print in a php page from this form > i try the following: > SELECT count(metodo) FROM pesquisa where serie= 'a' || 'A' having '5'" > > thios give me the error; > Warning: PostgreSQL query failed: ERROR: WHERE clause must return type bool, > not type unknown in /var/www/html/pesquisa/mnivela_teste.php on line 21 > ERROR If you are using '||' as a logical OR, that is incorrect. || is the concatenation operator in Postgres. You probably want serie = 'a' OR serie = 'A'. Your "having" clause is probably also incorrect, since it doesn't reference anything. Let's say that you have a table "votes" with question fields "field1", "field2", etc., with corresponding value fields "value1", "value2", etc. If you want to know how many of the rows in "votes" with "field1" = 'A' has a value of 5, you would have the following SQL: SELECT count( field1 ) FROM votes WHERE field1 = 'A' AND value1 = 5 If you want counts for all values for field1 (more efficient): SELECT count( value1 ) FROM votes WHERE field1 = 'A' GROUP BY value1 ORDER BY value1 Without your table schema, I can't recommend any further. Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet"