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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:39:27+00:00 2026-06-16T08:39:27+00:00

I have already asked this but question was closed without answer so I post

  • 0

I have already asked this but question was closed without answer so I post new question.
I am trying to add values that are missing in second table
in table ps_psroduct supplier some values are missing and I want to add the from ps_product. So I want to list values that are missing and insert them in ps_product_supplier, there is no duplication.
Some values from ps_product are same in ps_product_supplier but not all so I want to filter thoese values and insert them correctly.
So some values exists in ps_product but not in ps_product_supplier and I want to insert missing rows in table by checking id_product and add missing.
What I have for now is that I get all the values printed but I need only missing values that I can insert them in ps_product_supplier

How to do that?
In output I get:

USPJESNO ID 1 ne postoji u drugoj tablici i trenutno: 0
USPJESNO ID 2 ne postoji u drugoj tablici i trenutno: 1
USPJESNO ID 3 ne postoji u drugoj tablici i trenutno: 2
USPJESNO ID 4 ne postoji u drugoj tablici i trenutno: 3
USPJESNO ID 5 ne postoji u drugoj tablici i trenutno: 4
USPJESNO ID 6 ne postoji u drugoj tablici i trenutno: 5

for all the values, but I need to mach IDs and print only missing and create a row for it in ps_product_supplier with values from ps_product

$kveri = "SELECT id_product,id_supplier,supplier_reference, wholesale_price FROM ps_product";

    $ispis = mysql_query($kveri) or die(mysql_error());

               while ($row = mysql_fetch_array($ispis)){


               $trenutnired = $row['id_product'];
               $trenutnired1 = 0;
               $trenutnired2 = $row['id_supplier'];
               $trenutnired4 = $row['supplier_reference'];
               $trenutnired5 = $row['wholesale_price'];
               $trenutnired6 = 3;



                                                            //echo $trenutnired;

            //$drugatab = "SELECT * FROM ps_product_supplier WHERE id_product = '$trenutnired'";
            $drugatab = "SELECT id_product FROM ps_product_supplier WHERE id_product = '$trenutnired'";
            $rezultati = mysql_query($drugatab) or die(mysql_error());
                if(mysql_num_rows($rezultati)){
            // Successful query...

            echo "USPJESNO ID $trenutnired ne postoji u drugoj tablici i trenutno: $countUpdated<br />";
            //mysql_query("INSERT INTO ps_product_supplier (id_product_supplier, id_product, id_product_attribute, id_supplier, product_supplier_reference, product_supplier_price_te, id_currency)  VALUES ('', '$trenutnired', '$trenutnired1',  '$trenutnired2', '$trenutnired4', '$trenutnired5', '$trenutnired6')");
            $countUpdated++;
        } else {
            //$countUpdated++;
            echo "ID $trenutnired ne postoji u drugoj tablici i trenutno: $countUpdated<br />";
        }
        }

This query works for one ID to insert data but I need for all that are missing:

INSERT INTO ps_product_supplier 
(id_product_supplier, id_product, id_product_attribute, id_supplier,
product_supplier_reference, product_supplier_price_te, id_currency)  
VALUES(NULL, 6216, 0, (SELECT id_supplier FROM ps_product WHERE id_product = 6216),
(SELECT supplier_reference FROM ps_product WHERE id_product = 6216), 
(SELECT wholesale_price FROM ps_product WHERE id_product = 6216), 3);
  • 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-16T08:39:29+00:00Added an answer on June 16, 2026 at 8:39 am

    I think you’re trying to select products that are in ps_products, but are not in ps_productsuppliers. If I’m right about that, this way is probably the easiest to understand.

    select id_product
    from ps_products
    where id_product not in (select id_product from ps_product_supplier;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already asked this question on SuperUser but it was suggested there that
I guess this question that would have already been asked here. I searched but
I am sorry I have already asked this question on Superuser, but nobody answers
I am sorry, for I believe that this question has been asked already, but
I have already asked a similar question earlier but I have notcied that I
Actually I have already asked this question in official Q&A but didn't get any
I have already asked about this for android, but I will broaden the question
I have already asked this question in offical Flot google groups, but got no
I already asked this question, but in a way that confused people. So what
I have already asked a question about syntax highlighting, but this seems (to me)

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.