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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:34:28+00:00 2026-05-27T16:34:28+00:00

I’m working on a shop-like system (in PHP & MySQL) that exports invoices to

  • 0

I’m working on a shop-like system (in PHP & MySQL) that exports invoices to an external system. The proces goes something like this;

  • Customer orders a product and an invoice is created
  • XML is generated for this invoice and sent to the external server
  • External server handles XML and responds with another XML
  • System handles response.

For every XML that’s being sent to the external server a record is created in the database containing the corresponding invoicenumber and a status (status is initially SENT, indicating that the XML is sent.) After the system has handled the response the status is either SUCCESS or ERROR. Now, the problem is; at some point I want to fetch a list of invoices that have no record in the request table with status SUCCESS.

EDIT: If the status is ERROR there will be a new request for the same invoice, so there is a possibility that there will be more than one request per invoice.

My order table has columns ID and InvoiceNumber, and the request table has columns ID, InvoiceNumber and Status, so to get the list mentioned I could do something like:

SELECT InvoiceNumber 
FROM orders AS a
LEFT JOIN requests AS b
    ON a.InvoiceNumber = b.InvoiceNumber
WHERE NOT EXISTS (SELECT ID 
                       FROM requests 
                       WHERE status = "SUCCESS" 
                           AND request.InvoiceNumber = a.InvoiceNumber)

However, a second option would be to create an extra column to the order table (ie. requestSucces) being initially 0 and set to 1 if the system handles a successful response for the corresponding invoice. This would result in a much easier and less expensive query to get the list of invoices that need to be (re)sent (SELECT invoiceNumber FROM orders WHERE requestSuccess = 0), however the field would technically be redundant.

My question is: what would be better; use the easy query at the cost of having a redundant field or use the heavier query and not pollute the database with redundancy. Of course; if any of you know of a better solution without using redundancy that would be even better.

  • 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-27T16:34:29+00:00Added an answer on May 27, 2026 at 4:34 pm

    when you make the status field numeric error=0 and succes=1 one you could do a max status grouped by invoicenumber to see which invoices are no

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I would like to count the length of a string with PHP. The string
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.