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

  • SEARCH
  • Home
  • 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 7864993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:57:15+00:00 2026-06-02T23:57:15+00:00

I have this query string… select i.invoiceid, i.date, i.total, i.total – (select ifnull(sum(p.amount), 0)

  • 0

I have this query string…

select i.invoiceid, i.date, i.total, i.total - (select ifnull(sum(p.amount), 0) from payment p where p.invoice = i.invoiceid) as remainingbalance
        from invoice i inner join client c
        on i.client = c.clientid
        where i.isdeleted = 0 and i.client = 1
        union
        select p.paymentid, p.date, p.invoice, p.amount from payment p inner join invoice i
        on i.invoiceid = p.invoice
        inner join paymenttype
        on paymenttype.paymenttypeid = p.paymenttypeid
        inner join client c
        on c.clientid = i.client
        where c.clientid = 1
        and i.isdeleted = 0
        order by date

when I try this…

<?php
echo $clientArrayInvoice[1]['paymentid'];
?>

I get no results when I do a print_r on on $clientArrayInvoice I get this

Array ( [0] => Array ( [invoiceid] => 1 [date] => 2012-04-12 [total] => 602.29 [remainingbalance] => 300.96 ) [1] => Array ( [invoiceid] => 1 [date] => 2012-04-27 [total] => 1.00 [remainingbalance] => 301.33 ) )

I understand why its doing this, but how do I get the column to say paymentid instead of invoiceid for the results returned. so I can determine what is a paymentid and what is a invoiceid I hope this makes sense.

  • 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-06-02T23:57:16+00:00Added an answer on June 2, 2026 at 11:57 pm
    select i.invoiceid as transactionid, i.date, i.total, 
    i.total - (select ifnull(sum(p.amount), 0) from payment p where p.invoice = i.invoiceid) as remainingbalance,
    'invoice' as transaction_type
            from invoice i inner join client c
            on i.client = c.clientid
            where i.isdeleted = 0 and i.client = 1
            union
    select p.paymentid as transactionid, p.date, p.invoice, p.amount, 'payment' as transaction_type
            from payment p inner join invoice i
            on i.invoiceid = p.invoice
            inner join paymenttype
            on paymenttype.paymenttypeid = p.paymenttypeid
            inner join client c
            on c.clientid = i.client
            where c.clientid = 1
            and i.isdeleted = 0
            order by date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query to be run: string query = @SELECT * FROM hint
I have this example code: string query = select * from xy where id
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Let's ay I have this query: var results = from row in db.Table select
I have this query. SELECT purchase_log.id, purchase_log.date_purchased, purchase_log.total_cost, purchase_log.payment_status, cart_contents.product_name, members.first_name, members.last_name, members.email FROM
I have this query: $sql = SELECT * FROM tutorials WHERE ( device LIKE
I have this code so far: string userInput = Textbox1.text; string query = SELECT
I have this query be used on hibernate with java: String hql = select
I have this query below: $msgg = mysql_query(SELECT * FROM mytable WHERE time>$time AND
I have this query: SELECT device, COUNT(*) FROM database.table GROUP BY device HAVING count(*)

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.