From: | "Stefan Arentz" <stefan(dot)arentz(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Querying for name/value pairs in reverse |
Date: | 2006-07-15 09:24:17 |
Message-ID: | adf34c300607150224k7d4243f6ye52a21bf0a1bd0a6@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm no SQL expert by any means so I'm wondering if something like this
is possible.
I have two tables like this:
create table Errors (
Id serial not null,
CreateDate timestamp not null,
primary key (Id)
);
create table ErrorValues (
Id serial not null,
ErrorId int not null,
Name varchar(255) not null,
Value text not null,
primary key (Id),
foreign key (ErrorId) references Errors (Id)
);
Now, selecting specific ErrorValues with a bunch of names that are
related to an Error is of course pretty simple. But I want to go the
other way. I want to query for:
'give me all Errors that have the Code=1234 AND Address=1.2.3.4 AND
Type=OSX Name/Value pairs'
What is a good recipe to deal with this? Is something like this
possible with standard sql? Is there a nice PG way to do this?
Are there good books that cover real world stuff like this?
So many questions from a SQL noob.
S.
From | Date | Subject | |
---|---|---|---|
Next Message | sathiya moorthy | 2006-07-15 10:38:14 | Doubt about User-defined function. |
Previous Message | Mark Stosberg | 2006-07-14 15:44:10 | INSERT ... SELECT FROM .... FOR UPDATE? |