Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008

    Unanswered: Looking for SQL solution

    Hi There

    The following sql statement is not giving the right output, can anyone help

    I have 3 tables 1) workorder 2) matusetrans 3)wpmaterial

    table 1 has 1 record, t2 has 2 record & t3 has 2 record
    when i join them i am getting 4 records in which 2 records are duplicated, is there any way i can stop displaying the duplicate record, note i have used DISTINCT but it did not work.

    "SELECT matusetrans.itemnum, matusetrans.transdate, matusetrans.quantity,
    matusetrans.issuetype, matusetrans.description, wpmaterial.itemqty,
    FROM matusetrans, wpmaterial, workorder.wonum
    WHERE ( (Workorder.wonum= '108875')
    AND (matusetrans.refwo = wpmaterial.wonum)
    AND (Workorder.wonum = wpmaterial.wonum)
    AND (matusetrans.issuetype = 'ISSUE')

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    please show the actual rows, since there are so few of them

    also, this is wrong --

    FROM matusetrans, wpmaterial, workorder.wonum

    you can't pull rows from two tables and a column | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2004
    Hi, Sarah_1985. Since the three tables, workorder, matusetrans, and wpmaterial, contain few records, it would help if you could share the records. Also, may I know what you are trying to get from the query?

  4. #4
    Join Date
    Dec 2007
    The reason why the distinct doesnt work is one field is diferent - Identify that field and exclude it from your select statement. If it is a field that you need, then exculde the other info in the where clause.

Posting Permissions

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