Re: [SQL] exclusion query

2008-09-25 Thread Oliveiros Cristina

Hi, Louis-David,

I guess you already have your problem solved, but just for the sake of 
curiosity, another
way to do it might be to tweak a little your original query, I've written on 
Capitals the things I've added.
Should you need to exclude more than one event you can add the conditions to 
the commented line (ORed )


Best,
Oliveiros

select distinct pt.type
from person_type pt
natural join person_to_event
join event e using (id_event)
LEFT JOIN event e2
ON e.id_event = e2.id_event
AND e2.id_event=219 -- put here the id of the event you wanna exclude
join event_type et
ON e.id_event_type = et.id_event_type
where et.type_fr='théâtre'
GROUP BY pt.type_fr
HAVING SUM(e2.id_event) IS NULL;

- Original Message - 
From: "Louis-David Mitterrand" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, September 23, 2008 9:18 AM
Subject: Re: [SQL] exclusion query



On Mon, Sep 22, 2008 at 09:39:08AM -0700, Mark Roberts wrote:


Taking your second email into account, I came up with:

select distinct pt.type_fr
from person_to_event pte
inner join person_type using (id_person_type)
where id_person_type in (
select id_person_type
from person_to_event pte
inner join event using (id_event)
inner join event_type using (id_event_type)
where type_fr = 'theatre'
) and id_person_type not in (
select id_person_type
from person_to_event
where id_event = 219
)

I feel like there's a solution involving group by tugging at the back of
my mind, but I can't quite put my finger on it.  Sorry if this isn't
quite what you're asking for.


Hi,

That works very nicely (with minor adaptations).

I also had that solution-without-a-subselect in the back of my mind but
this does the job just fine!

Cheers,

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql




--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] exclusion query

2008-09-25 Thread Louis-David Mitterrand
On Thu, Sep 25, 2008 at 02:11:23PM +0100, Oliveiros Cristina wrote:
> Hi, Louis-David,
>
> I guess you already have your problem solved, but just for the sake of  
> curiosity, another
> way to do it might be to tweak a little your original query, I've written 
> on Capitals the things I've added.
> Should you need to exclude more than one event you can add the conditions 
> to the commented line (ORed )

That LEFT JOIN + GROUP BY trick is wicked! :-) I spent the last half 
hour struggling to understand it. You solution is a great learning tool 
and you obviously know your way around SQL.

Thanks!

> Best,
> Oliveiros
>
> select distinct pt.type
> from person_type pt
> natural join person_to_event
> join event e using (id_event)
> LEFT JOIN event e2
> ON e.id_event = e2.id_event
> AND e2.id_event=219 -- put here the id of the event you wanna exclude
> join event_type et
> ON e.id_event_type = et.id_event_type
> where et.type_fr='théâtre'
> GROUP BY pt.type_fr
> HAVING SUM(e2.id_event) IS NULL;
>
> - Original Message - From: "Louis-David Mitterrand" 
> <[EMAIL PROTECTED]>
> To: 
> Sent: Tuesday, September 23, 2008 9:18 AM
> Subject: Re: [SQL] exclusion query
>
>
>> On Mon, Sep 22, 2008 at 09:39:08AM -0700, Mark Roberts wrote:
>>>
>>> Taking your second email into account, I came up with:
>>>
>>> select distinct pt.type_fr
>>> from person_to_event pte
>>> inner join person_type using (id_person_type)
>>> where id_person_type in (
>>> select id_person_type
>>> from person_to_event pte
>>> inner join event using (id_event)
>>> inner join event_type using (id_event_type)
>>> where type_fr = 'theatre'
>>> ) and id_person_type not in (
>>> select id_person_type
>>> from person_to_event
>>> where id_event = 219
>>> )
>>>
>>> I feel like there's a solution involving group by tugging at the back of
>>> my mind, but I can't quite put my finger on it.  Sorry if this isn't
>>> quite what you're asking for.
>>
>> Hi,
>>
>> That works very nicely (with minor adaptations).
>>
>> I also had that solution-without-a-subselect in the back of my mind but
>> this does the job just fine!
>>
>> Cheers,
>>
>> -- 
>> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>>
>
>
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Problem with pg_connect() in PHP

2008-09-25 Thread James Kitambara
Dear Members of 
I have installed the Apache 2.0.61,  PHP 5.2.4 and PostgreSQL 8.1 on my local 
computer.
All three software were successfully tested. I changed 
“;extension=php_pgsql.dll”  to 
“extension=php_pgsql.dll”    in the php.ini file in order to enable PostgreSQL 
in PHP.
The problem comes when I try to connect to the PostgreSQL Database using php 
function pg_connect
$dbconn = pg_connect("host=".PG_HOST_NAME." port=".PG_PORT_NUM."  
dbname=".PG_DB_NAME." user=".PG_USER." password=".PG_PASSWORD); 
All the arguments in the function pg_connect() are defined.
Unfortunately I am getting the Fatal error: “Call to undefined function 
pg_connect() in C:\Web\html\Staff_Management\example1.php on line 23”
C:\Web\html is my document root.
What could be the possible mistake? 
Anyone to assist me!
Best regards,
James Kitambara


  

Re: [SQL] Problem with pg_connect() in PHP

2008-09-25 Thread Robert Edwards


Looks like you are missing the php_pgsql extension (I assume you
are running on a Windows server). On Debian GNU/Linux, it is called
php5-pgsql (or php4-pgsql, as appropriate). Not sure what it would
be called for Windows, but something similar.

Simply enabling it (by uncommenting the line in your php.ini file)
is not sufficient - the actual library needs to be installed as well.

Cheers,

Bob Edwards.

James Kitambara wrote:

Dear Members of

I have installed the Apache 2.0.61,  PHP 5.2.4 and PostgreSQL 8.1 on my 
local computer.


All three software were successfully tested. I changed 
“/;extension=php_pgsql.dll”/  to


/“extension=php_pgsql.dll”/in the php.ini file in order to enable 
PostgreSQL in PHP.


The problem comes when I try to connect to the PostgreSQL Database using 
php function pg_connect


$dbconn = pg_connect("host=".PG_HOST_NAME." port=".PG_PORT_NUM." 
 dbname=".PG_DB_NAME." user=".PG_USER." password=".PG_PASSWORD);


All the arguments in the function pg_connect() are defined.

Unfortunately I am getting the Fatal error: “/Call to undefined function 
pg_connect() in C:\Web\html\Staff_Management\example1.php on line 23/”


C:\Web\html is my document root.

What could be the possible mistake?

Anyone to assist me!

Best regards,

James Kitambara





--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql