PratikShah111
asked on
create a semicolon delimeted list
I want to insert into a table a semicolon delimeted values.
table 1 : userid
row 1 prs
row 2 ppp
so I do a select on table
select userid from table1
the resultset that i should get should be : prs;ppp
which I will go ahead and insert in table2 useridlist column
table2
useridlist
row1 prs;ppp
table 1 : userid
row 1 prs
row 2 ppp
so I do a select on table
select userid from table1
the resultset that i should get should be : prs;ppp
which I will go ahead and insert in table2 useridlist column
table2
useridlist
row1 prs;ppp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Such data is a bad idea, if you want to store userlists into a database, you'd have this design:
a) Users
ID, NAME
b) UserLists
ID, NAME
c) UsersInUserlists
ID, UserListID, UserID
To get a list of users:
This type of design is not just a theoretical idealized form of storing data. It is best practice. The UsersInUserlists can also be called an n:m relation, it's there to assign users to userlists or vice versa assign userlists to users.
Bye, Olaf.
a) Users
ID, NAME
b) UserLists
ID, NAME
c) UsersInUserlists
ID, UserListID, UserID
To get a list of users:
SELECT Users.* FROM UserLists
INNER JOIN UsersInUserLists On UsersInUserLists.UserListID = UserLists.ID
INNER JOIN Users ON Users.ID = UsersInUserLists.UserID
WHERE UserList.Name = 'list name' -- or if you know an ID value: WHERE UserList.ID = 3
This type of design is not just a theoretical idealized form of storing data. It is best practice. The UsersInUserlists can also be called an n:m relation, it's there to assign users to userlists or vice versa assign userlists to users.
Bye, Olaf.
Open in new window