From: | "Will Fitzgerald" <fitzgerald(at)inetmi(dot)com> |
---|---|
To: | "Aggarwal , Ajay" <ajay(at)crossbeamsys(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | RE: question on SELECT using LIKE |
Date: | 2000-11-04 15:57:23 |
Message-ID: | KPELIDPNOGGPCLGOMDLFOEALCEAA.fitzgerald@inetmi.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The thing is, this is the wrong thing to do. The relational model makes it
easy to define 'lists' or 'sets.' Table 2 should have:
table2
Name group
joe group1
mark group2
joe group3
linda group3
The table is now just what you want: it shows the groups each person is a
member of. So:
SELECT name, group FROM table2 ORDER BY name;
Will
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Aggarwal , Ajay
> Sent: Thursday, November 02, 2000 5:32 PM
> To: 'pgsql-general(at)postgresql(dot)org'
> Subject: [GENERAL] question on SELECT using LIKE
>
>
> Please respond to ajay(at)crossbeamsys(dot)com since I don't subscribe to the
> mailing list.
>
> I have 2 tables :
>
> Table1
> Name Age
> joe 23
> mark 25
> linda 22
>
> Table2
> NameList Group
> joe group1
> mark group2
> joe linda group3
>
> For each person in Table1, I want to list the groups that he/she
> is a member
> of. Table2 has the group membership information, but notice that
> the first
> column of Table2 is a list of names rather than a single name.
>
> I want to be able to use the the following SELECT call :
>
> SELECT t1.name, t2.group
> FROM table1 t1, table2 t2
> WHERE t2.namelist LIKE %t1.name%;
>
> But its not working. The problem is in '%t1.name%', the second operand of
> LIKE.
>
> Thanks in advance. Please Cc your reply to ajay(at)crossbeamsys(dot)com as well.
>
> Ajay
>
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2000-11-04 16:56:17 | Re: where to find postgresql jobs in the Washington, DC area?? |
Previous Message | Andrew Gould | 2000-11-04 15:49:04 | Re: question on SELECT using LIKE |