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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:24:24+00:00 2026-06-16T03:24:24+00:00

So I have this app, where users create expense reports. Each report has many

  • 0

So I have this app, where users create expense reports. Each report has many receipts, and I need to be able to let users delete their reports with the associated receipts. I have a sql statement now that does just that but it only works IF there the report has receipts, so if it has no receipts the report doesnt get deleted:

    mysql_query("DELETE expense_general, expense_receipts FROM expense_general JOIN expense_receipts ON expense_general.id = expense_receipts.expense_general_id WHERE expense_general.id = {$expenseID}");

$expenseID is the report record ID number. so I do I get the statement to delete the reports with no receipts?

  • 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-16T03:24:25+00:00Added an answer on June 16, 2026 at 3:24 am

    Use a LEFT JOIN query, i.e.

    DELETE expense_general, expense_receipts 
    FROM expense_general 
    LEFT JOIN expense_receipts ON expense_general.id = expense_receipts.expense_general_id 
    WHERE expense_general.id = {$expenseID}
    

    this will match on the expense_general table, regardless of whether there is anything linked in the expense_receipts table.

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

Sidebar

Related Questions

So basically my app has users of course and each user can create 5
In my rails app Users and Schools can create courses, and each course has
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I have a flex app which allows user to create some content. this content
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make
I have this line: @users = database['users'].find(:all).limit(10) it returns this object: <Mongo::Cursor:0x8759a858 namespace='app-development.users' @selector=:all
http://www.kidzoneapp.com/uses.html In this app, they somehow have an ability to protect users home button
I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I have developed a small web app. This app allows users to upload images.
Right now I have this social media app, where I'm implementing ratings on users

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.