Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Duplicate entries

    Hi Guys,

    I was wondering if there's anything wrong with this code:

    Code:
    <cfquery datasource="SSHInven" name="vAll">
    SELECT  
    	a.pType, a.sOnHand, a.DateModified,
    	b.wQuantity,
    	c.mcQuantity
     FROM iParts a, iWSpares b, iMSpares c
    </cfquery>
    I want to be able to select those particular fields from my DB, but, when I <cfoutput> it keeps repeating all seven items I have in the iParts table (I'm testing with that first to see what's going on). The <cfoutput> tag I have looks like:

    Code:
    <cfoutput query="vAll">
    #pType# | #sOnHand# <br />
    </cfoutput>
    And, like I said before, it just keeps repeating that same info about 7 times. Any particular reason why???

    Thanks in advance!!

  • #2
    New Coder
    Join Date
    Aug 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to make sure that your tables are properly joined in the query.

    Something like:
    SELECT
    a.pType, a.sOnHand, a.DateModified,
    b.wQuantity,
    c.mcQuantity
    FROM iParts a
    join
    iWSpares b
    on
    a.primary_key = b.foreignkey
    join
    iMSpares c
    on
    a.primary_key = c.foreignkey


  •  

    Posting Permissions

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