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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:59:08+00:00 2026-06-05T15:59:08+00:00

So I have 2 tables, invoices and invoiceitems. I am wanting to create a

  • 0

So I have 2 tables, invoices and invoiceitems. I am wanting to create a query that combines the two into one table for a report. The problem I am running into is my query is only returning the first row from tblinvoiceitems, not all that apply. See my code below. Thanks!

Here are the tables:

invoices
+------+----------+-------------+-------------+------------+----------+-------+---------+
|  id  |  userid  |   duedate   |  datepaid   |  subtotal  |  credit  |  tax  |  total  |
+------+----------+-------------+-------------+------------+----------+-------+---------+
| 662  | 436      | 2012-07-01  | 2012-06-05  | 1290.00    | 0.00     | 0.00  | 1290.00 |
+------+----------+-------------+-------------+------------+----------+-------+---------+
| 668  | 441      | 2012-07-01  | 2012-06-11  | 1290.00    | 0.00     | 0.00  | 1290.00 |
+------+----------+-------------+-------------+------------+----------+-------+---------+

invoiceitems
+------+-------------+----------+----------+---------+-----------------+----------+
|  id  |  invoiceid  |  userid  |   type   |  relid  |   description   |  amount  |
+------+-------------+----------+----------+---------+-----------------+----------+
| 1408 | 662         | 436      | Promo    | 436     | Setup Fee       | 295.00   |
+------+-------------+----------+----------+---------+-----------------+----------+
| 1409 | 662         | 436      |          | 0       | US Standard     | 995.00   |
+------+-------------+----------+----------+---------+-----------------+----------+
| 1425 | 668         | 441      | Promo    | 441     | Setup Fee       | 295.00   |
+------+-------------+----------+----------+---------+-----------------+----------+
| 1426 | 668         | 441      |          | 0       | US Standard     | 995.00   |
+------+-------------+----------+----------+---------+-----------------+----------+

The table I want:

newtable
+------+----------+-------------+-------------+-------------+---------+-----------+------------+
|  id  |  userid  |  invoiceid  |   duedate   |  datepaid   |  setup  |  hosting  |  subtotal  |
+------+----------+-------------+-------------+-------------+---------+-----------+------------+
| 1    | 436      | 662         | 2012-07-01  | 2012-06-05  | 295.00  | 995.00    | 1290.00    |
+------+----------+-------------+-------------+-------------+---------+-----------+------------+
| 2    | 441      | 668         | 2012-07-01  | 2012-06-11  | 295.00  | 995.00    | 1290.00    |
+------+----------+-------------+-------------+-------------+---------+-----------+------------+

Current query:

"INSERT INTO newtable SELECT
tblinvoices.id,
tblinvoices.userid,
tblinvoices.duedate,
tblinvoices.datepaid,
tblinvoices.subtotal,
tblinvoiceitems.invoiceid,
tblinvoiceitems.amount
FROM tblinvoices
INNER JOIN tblinvoiceitems ON tblinvoices.id = tblinvoiceitems.invoiceid";
  • 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-05T15:59:08+00:00Added an answer on June 5, 2026 at 3:59 pm

    You can try:

    SELECT 
      i.id AS InvoiceID, i.userid, ii.invoiceid, i.duedate, 
      i.datepaid, i.setup, i.hosting, i.subtotal
    FROM
      invoices i 
    INNER JOIN 
      invoiceitems ii ON i.id = ii.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have two tables, Invoices and InvoiceItems. When I delete an Invoice, I'd
I have two tables: invoices & invoice_items. I need a one to many relationship
I have two tables, one for invoices and one for incoming payments. An incoming
I have two tables invoices and pending_payments both of which have the following rows
I have tables linked by FK, I query on the first table using entity
I've often seen line_item tables for orders or invoices that copy one or more
I have two tables in a 2010 Access Database. One for Customers and One
i have these two simple tables: Invoices: ID       Date      ... 1    
I have a create view for invoices that is failing on db.SaveChanges() on the
I have a table called invoices with 3 fields (for the purposes of this

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.