Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yadhul's avatar

Any one can suggest One time password generator packages while authentication in laravel 5.1

i have a problem with mysql i have three tables

  1. business: having fields (business_id,name,business_name) 2.business_language : having fields (business_language_id,business_id,language_id) 3.language: having fields(language_id, language,preference)

their are thousands of business_ids in business i want to insert business_id's which are not present in business_language with language_id

can any one help pls in query..

0 likes
3 replies
JoerJoers's avatar

Hi @yadhul Have you solved your issue?

To know which business_ids are not present in the business_language table and that are with language_id, see the query below:

SELECT business_id 
FROM business
WHERE business_id NOT IN (SELECT business_id
                              FROM business_language 
                              WHERE language_id IS NOT NULL OR language_id <> '');

Then now you can insert those business_id that are not present based from the result of the query.

Also, i noticed that the title of this seems not related to the description :)

yadhul's avatar

hey hi @JoerJoers iam really happy and thanks for ur reply... i knw this subquary for listing out.... from business_lanaguges which are not present.. i want a query where thousands of business_id's are not their.. it should insert in business_language with one single query it should insert multipel ids... that how iam not able to get it

Upadte business_language ..?

JoerJoers's avatar

I guess inserting multiple business ids using a single query is not possible. You need to do it one by one. However, using seeders can actually work. Create a seeder by following instructions here https://laravel.com/docs/5.2/seeding then on the run function do the following:

public function run()
    {
       $businessIds = DB::table('business')
            ->whereNotExists(function ($query) {
                $query->select(DB::raw(1))
                      ->from('business_langauge')
                      ->whereRaw('business_language.business_id = business.id');
            })
            ->get();

    foreach ($businessIds as $businessId) {
            //Do the insert process here for each business_id
    }
    }



Please or to participate in this conversation.