Query of Queries?

Posted: 02-18-2005, 06:03 PM
I have a table named therapists with a field named modalities which contains a
comma delimited list of id #s. I need to loop through a list of modality id #s
and return results for each id #. Explanation - I need to find the
therapist(s) whose modality field contains the modality id in the list i am
looping through. Does that make sense?... In other words i need to search a
table for therapists who offer a certain modality (the therapists modalities
are stored as a comma delimited list in a field). Please help!

Reply With Quote

Responses to "Query of Queries?"

klutzoid
Guest
Posts: n/a
 
Re: Query of Queries?
Posted: 02-18-2005, 08:46 PM
how about:
select *
from therapists
where modalities like '%1234567%'
Reply With Quote
zoeski80
Guest
Posts: n/a
 
Re: Query of Queries?
Posted: 02-21-2005, 02:43 AM
Hi Andrew

You can do the query like klutzoid suggested first but then I think you'll
need to loop through the query results to make sure that the ID isn't a subset
of another ID.

eg.
therapist modality: 12345,67890
if you're searching for ID = 345 it will find this therapist but they don't
really have that modalidy ID in this list (it is just a subset of modality
12345)


If you are able to modify the DB a better way would be to have a separate
TherapistModality table which therapist_id and modality_id columns
SELECT therapist_id
FROM therapistModality
WHERE modality_id = #id#
(the database would be better normalised then too)

Zoe

Reply With Quote
artists_envy
Guest
Posts: n/a
 
Re: Query of Queries?
Posted: 02-25-2005, 03:31 PM
Thanks to both of you for the help. I had previously used an access DB with a
modalitiesofferred table which held the therapist's id number and the modality
id number(one record for each of the therapist's modalities). I thought
perhaps that i could find a better way to approach this but, it seems that the
best/easiest way is to go back and use the same DB structure(i am using ms sql
now). Thanks again for your help. Andy

Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Query Error BigNicko7 Coldfusion Database Access 6 05-06-2005 07:40 PM
Query returns no rows... chrson Coldfusion Database Access 4 04-05-2005 04:32 PM
Query problem part 2 tejun Coldfusion Database Access 1 02-21-2005 09:40 PM
Need SQL Query Help from Gurus ctrl+alt+delete Coldfusion Database Access 4 02-18-2005 08:20 PM
query problem tejun Coldfusion Database Access 10 07-11-2003 09:21 AM