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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:11:51+00:00 2026-06-13T09:11:51+00:00

Thanks for looking! Background I have virtually no experience with the LAMP stack, but

  • 0

Thanks for looking!

Background

I have virtually no experience with the LAMP stack, but I have recently started an online store that uses OpenCart which is based on the LAMP stack.

The store allows for me to assign reward points to customers and I am giving each new customer 10 points just for creating an account.

Unfortunately, the OpenCart admin GUI only allows me to do this manually, one user at a time.

I do, however, have access to an interface that will allow me to run MySql commands and I would like to solve the problem using this approach.

Within the database created by OpenCart, I have a oc_customer table which contains all of my customers, and then I have a oc_customer_reward table which keys off of the customer id and assigns a new record each time a customer is awarded points. Here is what that looks like:

oc_customer_reward

Question

How do I write a MySql query that will see if a customer from oc_customer does NOT exist in the oc_customer_reward table and IF THEY DO NOT EXIST, then create a record in the oc_customer_reward table (worth 10 points) for that customer?

I am not asking for working code (unless you really want to provide it) and I am willing to do the work myself, but frankly I don’t know where to start. What would be the approach?

UPDATE

Per Olaf’s suggestion, I am able to get all customers NOT in the oc_customer_reward table with his suggested query:

SELECT customer_id
FROM oc_customer
WHERE customer_id NOT 
IN (
SELECT customer_id
FROM oc_customer_reward
)

Now, I just need to iterate the results of that query (sorry I am not a database guy!) and insert a row in oc_customer_reward for each of them. Kind of like a foreach loop in C#. Any thoughts?

  • 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-13T09:11:52+00:00Added an answer on June 13, 2026 at 9:11 am

    First find customers not in the reward table:

    select customer_id from oc_customer
        where customer_id not in (select customer_id from oc_customer_reward);
    

    then take that and insert an entry into the reward table:

    insert into oc_customer_reward (customer_id, points)
        select customer_id, 10 from oc_customer
            where customer_id not in (select customer_id from oc_customer_reward);
    

    This is not tested, but I hope it helps for a start.

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

Sidebar

Related Questions

Hi and thanks for looking! Background I have a computing task that requires either
Hi and thanks for looking! Background I have a workflow that constructs a set
Thanks for looking on this problem. I have a page that is totally valid
Hi and thanks for looking! Background I have inherited an old .NET project based
Hello and thanks for looking! Background I currently have a C# method for looping
I just started 5 hours ago with web services. I have some background but
Hi and thanks for looking! Background I have made a simple little app in
Hi and thanks for looking! Background I have been developing .NET Web applications for
Hi and thanks for looking at this newbi question. I have looked for anykind
Hi and thanks for looking! Background I need to pull the file locations (path

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.