SQL Query problem.

Results 1 to 2 of 2

Thread: SQL Query problem.

  1. #1
    Join Date
    Dec 1969

    Default SQL Query problem.

    I have a table that I would like to select information out of....There are a total of 52 records in that table....after I make the SQL Query, I only want those 52 records....but with a column from the Matr table. The only way to get to that table is through another table. When I introduce any other tables....I keep getting extra "copies" of the information in the table I want. <BR><BR>Basically out of PNCD table, I want Component, Code, Description and the MColumn that goes with it. <BR><BR>Here are the tables: <BR><BR>PNCD --&#062; Component, Code, Description <BR>PNCK --&#062; Component, MatrixID <BR>Matr --&#062; MatrixID, MColumn <BR><BR>PNCD.Component = PNCK.Component and <BR>PNCK.MatrixID = Matr.MatrixID <BR><BR>Can someone help?

  2. #2
    Join Date
    Dec 1969

    Default Well, you'll always get multiple...

    ...records in the result if there are multiples in one of the "connected" tables.<BR><BR>A simple example, using your tables:<BR><BR>PNCD --&#062; Component, Code, Description<BR> 17 :: CX1817 :: Left handed widget<BR><BR>PNCK --&#062; Component, MatrixID <BR> 17 :: 342<BR> 17 :: 901<BR><BR>Matr --&#062; MatrixID, MColumn <BR> 342 :: White<BR> 901 :: Black<BR><BR>And if you JOIN those three tables, WHAT CHOICE does the poor DB have but to give you back:<BR> 17 :: CX1817 :: Left handed widget :: 342 :: White<BR> 17 :: CX1817 :: Left handed widget :: 901 :: Black<BR><BR>???<BR><BR>How is *IT* supposed to choose WHICH of the two "Matr" records to return to you?<BR><BR>**********<BR><BR>NOW...<BR><BR>You *can* force the system to get only one of the "Matr" records per "PNCD" record, but YOU have to be the one to specify WHICH ONE.<BR><BR>So show some REAL data (instead of my made up crap) and TELL us how you want it to choose WHICH MColumn it should get.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts