I have 2 tables in mysql Database (mariaDB) name products and order.
In product table there is column productid which is type of int(11)
and set as primary key as well as auto increment. While order table has reference of productid column
the name is not same and no foreign key is used . The name of column in order
table is set to pid
and type is varchar
.
I want all the rows from products
table whose productid
is not present in order
table .
this databases is used by an android application as well as web application. so major changes like renaming columns is not feasible.
My current approach is using programing . Get list of all productid
from products
and then search for them in order
table one by one . This is taking a lot of time as number of products in table are about 500k
Is there any other way to achieve this?