Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:59:01+00:00 2026-05-22T23:59:01+00:00

Got a question regarding SQL and ColdFusion: I can’t write SQL code properly, so

  • 0

Got a question regarding SQL and ColdFusion: I can’t write SQL code properly, so that it won’t repeat the variables twice. So far I’ve got:

<cfquery name="get_partner_all" datasource="#dsn#">
    SELECT  
    C.COMPANY_ID,
    C.FULLNAME,
    CP.MOBILTEL,
    CP.MOBIL_CODE, 
    CP.IMCAT_ID,
    CP.COMPANY_PARTNER_TEL, 
    CP.COMPANY_PARTNER_TELCODE,
    CP.COMPANY_PARTNER_TEL_EXT,
    CP.MISSION, 
    CP.DEPARTMENT, 
    CP.TITLE,
    CP.COMPANY_PARTNER_SURNAME, 
    CP.COMPANY_PARTNER_NAME, 
    CP.PARTNER_ID, 
    CP.COMPANY_PARTNER_EMAIL, 
    CP.HOMEPAGE, 
    CP.COUNTY,
    CP.COUNTRY,
    CP.COMPANY_PARTNER_ADDRESS, 
    CP.COMPANY_PARTNER_FAX,
    CC.COMPANYCAT,
    CRM.BAKIYE,
    CRM.BORC,
    CRM.ALACAK
    FROM
        COMPANY_PARTNER CP,
        COMPANY C,
        COMPANY_CAT CC,
        #DSN2_ALIAS#.COMPANY_REMAINDER_MONEY CRM
    WHERE
                C.COMPANY_ID = CP.COMPANY_ID
    AND C.COMPANY_ID = CRM.COMPANY_ID
    AND C.COMPANYCAT_ID = CC.COMPANYCAT_ID

As you can see definition C.COMPANY_ID is repeated twice, so the variable shown also twice, but I need this (CRM) definition to display some money issues.

Can anyone show me how I can define it in a different way so that the output of this code won’t repeat the variables?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:59:02+00:00Added an answer on May 22, 2026 at 11:59 pm

    I assume you mean that you get multiple columns in the result set, each with the name “COMPANY_ID”. The solution to this is to specify specific columns from all of the tables, instead of SELECT * (not just for the COMPANY_CAT table, alias CC).


    If you’re getting “repeated” rows, then you need to examine the contents of these rows. What’s happening there is that one or more rows from another table is matching one row from the “COMPANY” table. Each matching pair of rows generates a row in the output. Now you’ve expanded your column list, compare a pair of rows which have the same COMPANY_ID – in which columns do they differ? If it’s in, say, the last 3 columns, then there are multiple rows in CRM which match the same COMPANY_ID.

    Once you’ve identified the other table that is causing duplicates to occur, you need to decide how to limit them – should you be aggregating values from that table (e.g. SUM or MAX), or is there a way to further refine which row from the other table you want to match to the row in COMPANY.

    At a guess though, I’d speculate that one company could have multiple partners…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a question regarding a SQL-select-query: The table contains several columns, one of
I've got a question concerning fields in databases which are measures that might be
I've got a question about testing methods working on strings. Everytime, I write a
So I've got a large database that I can't hold in memory at once.
got a question regarding printing out the 128 first characters from the ascii table.
I got a question regarding C++ Object & Javascript Object life cycle mis-synchronization and
Reading over the responses to this question Disadvantages of Test Driven Development? I got
Just got a question about generics, why doesn't this compile when using a generic
I got this question from this discussion . A method call like object.m does
So I got this question from one of the developers in my team: What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.