Jump to content

Recommended Posts

Hi All,

I am querying 4 specific things at the same time that all relate to one another and I need at least 5 tables in order to gather the correct material. I was successful at doing this; however, most of the the time the query that I am using brings back the same thing multiple times. For example:

This is my query:
[color=red]$query = "SELECT topicfile.filename,commentstate.fileline, commentdata.commentfield,
commentstatehistory.metric_value    FROM
commentstate, commentdata, topic, topicfile, commentstatehistory  WHERE
commentstate.id=commentdata.commentstateid
AND commentstate.topicid = '$topic_id' AND topic.id = '$topic_id' AND
commentstate.filenumber=topicfile.sequence AND
commentstate.topicid=topicfile.topicid AND commentstatehistory.id=commentstate.id";[/color]
And this is my output: (I am only trying to see this once, not four times)

[color=red]Filename                                                                                      Line #      Description    Defect Type
6.x-nightly/vobs/checkmc/cmc_api/system/checkmc/include/checkmc.h  61  Review  Complete    Submitted
6.x-nightly/vobs/checkmc/cmc_api/system/checkmc/include/checkmc.h  61  Review  Complete    Submitted
6.x-nightly/vobs/checkmc/cmc_api/system/checkmc/include/checkmc.h  61  Review  Complete    Submitted
6.x-nightly/vobs/checkmc/cmc_api/system/checkmc/include/checkmc.h  61  Review  Complete    Submitted [/color]

I just don't know why it does that. Anyone ever run into this problem before? Or know how to fix it? My only guess is the way that I matched the variables after the WHERE in my query.
Link to comment
https://forums.phpfreaks.com/topic/15174-querying-bringing-about-multiplicity/
Share on other sites

Also should make sure you don't have a one to many relationship with one of the tables. If ANY of the id's appear more than once in ANY table, you will get multiple lines. Just because the fields you are pulling out are the same does not mean other fields have different data.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.