You forgot 'FROM video_cart' before the WHERE clause, but I figured it out. Thanks for the quick help.
Main Topics
Browse All TopicsI need help writing a SQL query. Here's what I want to do.
I have 2 tables, video_cart & video_orders
They both have the same columns & names, but video_orders has 4 additional columns
Column names are: (video_cart & video_orders)
ID
Category
Title
Time
Video_Number
Add_Date
UserID
UserName
Name
Video_orders has the additional fields:
Order_Number
Status
Ship_Date
Return_Date
I want to be able to Insert into video_order from video_cart where the userid = 2 and at the same time have it add values to the columns order_number & status.
I want the order number to be the same for each record, but increment up each time the query is run. Status just needs to have the value 'Pending'.
Thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: aneeshattingalPosted on 2009-11-05 at 12:16:34ID: 25753460
insert into video_order(ID,Category,Ti tle,Time,V ideo_Numbe r,Add_Date ,UserID,Us erName,Nam e, Order_Number, Status) eo_Number, Add_Date,U serID,User Name,Name,
SELECT ID,Category,Title,Time,Vid
ISNULL( (SELECT MAX(Order_Number) from video_order WHERE UserID = 2 ),0) +1,
'Pending'
WHERE userid = 2