From: listrec <listrec@epecon.de>
To: Shahbuddin Md Isa <shahi@unitar.edu.my>
To: pgsql-sql@postgresql.org
Subject: Re: Merge Record in Database(SQL Statement)
Date: Mon, 7 Jul 2003 11:19:07 +0200
Message-ID: <PCEJJIGCHIJCOOOGFAFEKEOGCAAA.listrec@epecon.de> (raw)
In-Reply-To: <200307070123.h671Nh119524@mail.umm.com.my>
Not quite sure what the question is....
Assuming, you would like to normalize the data, I suggest to create 4
tables:
create table gpa (id integer primary key,gpa varchar(32) not null unique);
create table major (id integer primary key,major varchar(32) not null
unique);
create table birthplace (id integer primary key,birthplace varchar(32) not
null unique);
create table xxx (
id integer primary key,
attributename varchar(64) not null, -- this might be unique too
id_major integer references major(id),
id_birthplace integer references birthplace(id),
id_gpa integer references gpa(id)
);
insert into gpa (id,gpa) values (1,'excellent');
insert into major (id,major) values (1,'science');
insert into birthplace (id,birthplace) 1,'India');
insert into xxx (id,attributename,id_major,id_birthplace,id_gpa) values
(1,'Record 1',1,1,1);
insert into xxx (id,attributename,id_major,id_birthplace,id_gpa) values
(1,'Record 2',1,1,1);
Now selecting the records would be something like:
select x.attributename,m.major,b.birthplace,g.gpa from attributename a,major
m,birthplace b,gpa g
where x.id_major=m.id and x.id_birthplace=b.id and x.id_gpa=g.id
Hope that helps....
Detlef
-----Ursprüngliche Nachricht-----
Von: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]Im Auftrag von Shahbuddin Md Isa
Gesendet: Montag, 7. Juli 2003 03:24
An: pgsql-sql@postgresql.org
Betreff: [SQL] Merge Record in Database(SQL Statement)
Hai..
How to merge record in database(sql statement) if record same attribute,
examples:-
Attribute Major Birth_Place GPA
Record 1 science India excellent
Record 2 science India excellent
Please help me..
____________________________________________________________
Powered by Fastmail from http://www.i-fastmail.com
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: listrec@epecon.de, shahi@unitar.edu.my
Subject: Re: Merge Record in Database(SQL Statement)
In-Reply-To: <PCEJJIGCHIJCOOOGFAFEKEOGCAAA.listrec@epecon.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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