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

The Archive Base Latest Questions

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

I asked almost the same question before, but I cannot use the MERGE syntax

  • 0

I asked almost the same question before, but I cannot use the MERGE syntax because of a sequencer. The problem is that we have price rules for people in a database. I want to synchronise these price rules for other people that should have the same rules.

+---------------------------+
| id | name | belongs_to_id |
|----+------+---------------+
| 1  | A    |               |
| 2  | B    | 1             |
| 3  | C    | 1             |
| 4  | D    |               |
+----+------+---------------+

Ok so now people B and C need, eventually, to have the same price rules as user A. So I have a pricerule table (simplified) like this:

+-----------------------------------+
| id | user_id | product_id | price |
+----+---------+------------+-------+
| 1  | 1       | 1          | 0.12  |
| 2  | 1       | 2          | 0.10  |
| 3  | 1       | 3          | 0.03  |
| 4  | 2       | 2          | 0.10  |
| 5  | 2       | 3          | 0.10  |
| 6  | 3       | 1          | 0.12  |
| 7  | 3       | 2          | 0.10  |
| 8  | 3       | 3          | 0.03  |
| 9  | 3       | 4          | 0.25  |
+----+---------+------------+-------+

So in this example, what should happen is:

  • Give user 2 his price for product 1 with price 0.10
  • Update price for user 2 product 3, to 0.03
  • Delete price rule for user 3, product 4

I figured I have to take three steps: delete, update, add. I got the first two. But I’m thinking in circles about the insert statement. Basically I need to select all the price rules for user 1, then left join by product_id for each user. How do I do this for each user?

I am using Oracle 10.1

  • 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-02T16:15:04+00:00Added an answer on June 2, 2026 at 4:15 pm
    INSERT INTO
      priceRule
    SELECT
      user.id,
      parentPriceRule.product_id,
      parentPriceRule.price
    FROM
      user
    LEFT JOIN
      priceRule    AS parentPriceRule
        ON  parentPriceRule.user_id = user.belongs_to_id
    LEFT JOIN
      priceRule    AS myPriceRule
        ON  myPriceRule.user_id     = user.id
        AND myPriceRule.product_id  = parentPriceRule.product_id
    WHERE
      myPriceRule.id IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked the almost the same question before also, but i have not yet
I know that question with same title has been asked almost 6 month ago.
I asked Almost this exact same question yesterday. Basically I have a css button
Similar questions have been asked before but not quite the same (unless I missed
It's almost a year ago that I asked this question on SO: Menu Accelerator
This question has been asked here before, but the author wasn't very clear and
While it seems that this has been asked many times before, but there's a
I've seen this question being asked 1000 times, but I'd tried almost all methods
I know this question has been asked so many times before but I couldn't
I'm 10000000% sure that this question has been asked before, however, the majority of

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.