Helpful Information
 
 
Category: ColdFusion
Duplicate entries

Hi Guys,

I was wondering if there's anything wrong with this 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:



<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!!

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










privacy (GDPR)