dimanche 4 décembre 2016

Copy column values from multiple table and insert into 3rd table in Laravel

TABLE ShippingOrder ( ISBN int(11) NOT NULL, warehouseCode int(11) NOT NULL, username varchar(50) NOT NULL, number int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

TABLE Contains ( ISBN int(11) NOT NULL, basketID varchar(50) NOT NULL, number int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

TABLE Stocks ( ISBN int(11) NOT NULL, warehouseCode int(11) NOT NULL, number int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

TABLE ShoppingBasket ( basketID varchar(50) NOT NULL, username varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I wish to populate 'ShippingOrder' with 'Contains.ISBN', 'Contains.number', 'Stocks.warehouseCode' and for username, I am getting it from a join between 'Contains.basketID' = 'ShoppingBasket.basketID'

I have this working for me in mysql- INSERT INTO ShippingOrder (SELECT DISTINCT co.ISBN, s.warehouseCode, sb.username, co.number FROM Contains co INNER JOIN Stocks s INNER JOIN ShoppingBasket sb ON co.ISBN = s.ISBN AND sb.basketID=co.basketID AND co.basketID='".$basketID."' GROUP BY co.ISBN)

I don't understand how I can execute this in Laravel 5+. I can run simple queries but I have no clue how to run the one mentioned above. Thank you.like this



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gFc0Hn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire