Reputation: 521
I'm currently using MySQL to insert data manually to my database for learning purposes and I've stumbled across a slight confusion amongst one part, which I thought I cracked after reading a topic on here, however it doesn't insert anything but doesn't give an error either.
Here's the code that I've entered which returns no errors but does nothing either:
INSERT INTO Deliveries (O_ID,ShipDate,ArrDate,Del_Comp)
SELECT O_ID,'2012-10-21','2012-11-02','City Link'
FROM Orders
WHERE O_ID=1;
What I'm basically trying to do, is select an ID from the Orders
table (preferably a wildcard if possible), and then add custom information in the same row before adding it to the Deliveries
table. So I'll obviously end up with my first row being all the information that's on the SELECT row.
Upvotes: 1
Views: 118
Reputation: 5534
The part which is wrong is SELECT O_ID,'2012-10-21','2012-11-02','City Link'
which gives a combination of INSERT using values and INSERT using SELECT subquery.
You want to specify column names to SELECT, not actual values.
Upvotes: 1