|
Posted by GGG on 04/14/07 03:40
I have the following query:
$inquiry="SELECT * FROM dtartwork as da JOIN avaprints ON
da.id=avaprints.id ";
$inquiry.="LEFT JOIN dtimg ON da.id=dtimg.id WHERE da.id=$idm".
Dealing with 3 tables
My motivation is to show all the records affilaited with $idm. ($idm
is a call from a previous page, and is needed to match up the right
record with the right details)
What the above is doing:
It shows different records, when it comes to the subtables, dtimg,
avaprints... That's not the problem.
What is annoying, and maybe, this is just an oversight, is, when I
deal with the primary table, it'll show the same value twice (or 3 or
4 times, depending on how many records are in the sub tables.), in the
resulting script/query Is there a way to keep the db call from
showing the two records (because there is 2 different associated
records in avaprints?
to return the right amount of "main records" always one), or do I have
to do what I did in another settings: Break each table down, query
it, and then match them up with $idm?, and then show the records when
I need them? I can see this working on a small scale, but what
do larger scale operations do if they are met with a situation like
this? Breaking down the tables and writnig individual mysql calls,
could get old, fast.
I'm looking for the script to show one record, when it is required to,
and the subrecords in a different area of the same form, will display
whatever is associated with the record chosen-- this could be 0 or
more (one to many)
thanks for your help
Navigation:
[Reply to this message]
|