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
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire