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 1808142
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:13:28+00:00 2026-05-17T06:13:28+00:00

I have two tables, arrc_PurchActivity and arrc_Voucher. The purchase activity table contains multiple records

  • 0

I have two tables, arrc_PurchActivity and arrc_Voucher. The purchase activity table contains multiple records per purchase, tied together by the credit card authorization. I need to return a single row per purchase, plus pull in a field from the voucher table.
If I just grab a few fields from the purchase activity table, like this:

SELECT group_concat( VoucherID ) , CcAuthCode FROM arrc_PurchaseActivity GROUP BY CcAuthCode

it works fine, returning something like this:

group_concat( VoucherID )  | CcAuthCode
=========================================
610643,611139,610642       | 8LUPDN

What I need to do is pull in another contatenated field (VoucherNbr), this time from the arrc_Voucher table, where the voucher table’s VoucherID is equal to the purchase table’s VoucherID. In this case, because VoucherID is a concatenation, I need to return a concatenated column of VoucherNbr for each VoucherID in the concatenated column. Clear as mud, right? What I need would look like this:

group_concat( VoucherID )  | group_concat( VoucherNbr)  |  CcAuthCode
===========================|============================|=============
610643,611139,610642       | 123,456,789                |  8LUPDN 

In other words, the VoucherNbr for VoucherID 610643 is 123, VoucherNbr for 611139 is 456, etc.

Can anyone help me out? This is way over my head…

  • 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-17T06:13:29+00:00Added an answer on May 17, 2026 at 6:13 am

    Use:

       SELECT pa.ccauthcode,
              GROUP_CONCAT(DISTINCT pa.voucherid) AS voucherids,
              GROUP_CONCAT(v.vouchernbr) AS vouchernbrs
         FROM ARRC_PURCHASEACTIVITY pa 
    LEFT JOIN ARRC_VOUCHER v ON v.voucherid = pa.voucherid
     GROUP BY pa.ccauthcode
    

    I specified the DISTINCT in the GROUP_CONCAT for the voucherid’s because it’s possible you’d have multiple vouchernbr’s to a voucherid. If not, remove the DISTINCT.

    The LEFT JOIN ensures you’ll get ARRC_PURCHASEACTIVITY records that do not have supporting records in ARRC_VOUCHER. Change “LEFT JOIN” to “JOIN” if you don’t want this behavior.

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

Sidebar

Related Questions

I have two tables like Parent-Child. In Parent table, there are 7211 records. In
I have two tables that are joined together. A has many B Normally you
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
Have two tables with a linking table between them. USERS +-------+---------+ | userID| Username|
I have two tables: CREATE TABLE 'sales_sheet' ( `_id` int(11) NOT NULL AUTO_INCREMENT, `_typed_by`
I have two tables that I want to join into one table and use
I have two tables as follows PRODUCT table Id | Name | Price And
I have two tables Table : 1, Name : NdcAwp, Columns-Ndc, AwpUnitCost Table :
I have two tables with identical schemas and composite keys, table a and table

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.