This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > February 2006 > Complex query





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Complex query
Jamal Dayes

2006-02-12, 6:43 pm

Hi, I have a query and a results page that i want to use to allow users to
search for CD's by subject type. The Relationship is M:N because One CD can
have many different subject types and one subject can below to many different
CD's

I have 3 tables set up as follows:

CDtable:
cdName
cdId

SubjectTable:
subName
subId

Relationship
subId
cdId

The query page dynamically produces the checkboxes in a list as pulled
directly from the subjectTable. this is so that the end user can add more
subject types to the table and they will automatically update the checkbox
list.
What I need to do is produce a query that will take the selected checkboxes
and match them against the relationship table to produce a list of all the CD's
that match "ANY" of the subject types that were searched.

This query has been racking my brains. Firstly because I assume I have to take
the checkbox data and covert it in a string as the field type is the same for
each subject type.

if(is_array($_POST))
$_POST=implode(",",$_POST);

something like this would do the trick.

I'm just finding it impossible to get the query right?

SELECT CDtable.cdName, SubjectTable.subjectName, Relationship * FROM CDtable,
SubjectTable, Relationship WHERE IN ('%%%s%%') ORDER BY CdName

%%%%s%% - being my form posted variable.

This is doing my head in just thinking about. Can anyone point me in the right
direction or tell me where i'm going wrong.

Kind Regards

bregent

2006-02-12, 6:43 pm

Why start another identical thread? Go back and read the replies to your first post.
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews