Ask a Question related to Coldfusion Database Access, Design and Development.
-
Flashm@n #1
Comma Seperation List and Join Statement
Hi
I have a table with a field that contains a comma sperated list of userID's
(e.g c43, c45, c48). I'm trying to join the users table with this table to
pull out the firstname and surname of each user in the list. If the list only
contains one user (eg C43) the join statement works perfectly and the user
details are return and outputted via coldfusion.
The problem I have is outputing the users details when there are multiple user
id's in the field. I thought I could use the cfquerypara and specifie the
field as a list but either I have not set this up correctly or I am not
outputting the result properly.
Does anyone have a solution?
Thanks
Mark
Flashm@n Guest
-
Sproc Result as Comma Seperated List
Hey guys, I had built some photoblogging software in the past and am currently just revising it to bring it up to validated xhtml and running... -
Comma displays in List?
Hi there, I've done a few searches and couldn't find this question posted yet, so please forgive me in advance if its a reapeat. I have an XML... -
Need help with SQL statement for JOIN-type stuff
Mike wrote: > "Bob Barrows " <SPAMcom> wrote in message > news:<phx.gbl>... >> Mike wrote: >>> >>> So, does anyone know how to 1) turn off... -
comma delimited list problem
I have a comma delimited list that is loaded into flash using loadvars. How can I convert it into an array? thanks in advance. Shaun -
Splitting Comma delimited list
Hello everyone, I use the following to split a comma delimited list and get varying results and I don't understand why. my count of the... -
Brian Hogue #2
Re: Comma Seperation List and Join Statement
If I understand your question, then something like
select
FirstName,
LastName
from
yourTable
where
userid in (yourList)
where yourList is (c43, c45, c48). You may or may not need
userid in (#yourList#)
hth
-brian
"Flashm@n" <webforumsuser@macromedia.com> wrote in message
news:d61pam$sot$1@forums.macromedia.com...userID's> Hi
>
> I have a table with a field that contains a comma sperated list ofto> (e.g c43, c45, c48). I'm trying to join the users table with this tableonly> pull out the firstname and surname of each user in the list. If the listuser> contains one user (eg C43) the join statement works perfectly and the user
> details are return and outputted via coldfusion.
>
> The problem I have is outputing the users details when there are multiple> id's in the field. I thought I could use the cfquerypara and specifie the
> field as a list but either I have not set this up correctly or I am not
> outputting the result properly.
>
> Does anyone have a solution?
>
> Thanks
>
> Mark
>
Brian Hogue Guest
-
philh #3
Re: Comma Seperation List and Join Statement
This is a common error. You can't put related keys in a comma-separated list
in a field and expect them to represent a relationship. That's what RDBMS is
for, and what relational design is for.
You need what's called a "many-to-many" relationship, i.e., many students can
be related to more than one record in your target table.
Consider this structure:
USERS
ID
firstname
lastname
DETAILS
ID
desc
(etc.)
USERSDETAILS
ID
user_fk
details_fk
That comma-delimited list you have should be broken up and placed in the
USERSDETAILS table. Then you can do correct relational queries:
SELECT a.firstname,a.lastname, c.desc FROM DETAILS
JOIN USERSDETAILS b on b.details_fk = a.ID
JOIN USERS c on c.ID = b.user_fk
And, to get just one, add
WHERE c.ID = #thedetailprimarykey#
HTH,
philh Guest



Reply With Quote

