ki_ki
asked on
INSERT INTO query
Hi all,
I think this is easy...Is't possible to insert a new record using values from another record(using a subquery) AND values i want to insert (using the VALUES clause)? Or do I have to run two INSERT INTO querries? Hope it's clear. Thanx
I think this is easy...Is't possible to insert a new record using values from another record(using a subquery) AND values i want to insert (using the VALUES clause)? Or do I have to run two INSERT INTO querries? Hope it's clear. Thanx
ASKER
You mean? --->
INSERT INTO [salesOrderTable] (customerID, SOnumber, status)
SELECT (customerID, SOnumber) FROM [salesOrderTable] WHERE SOnumber= someVariable
UNION
VALUES ('Status_Pending')
INSERT INTO [salesOrderTable] (customerID, SOnumber, status)
SELECT (customerID, SOnumber) FROM [salesOrderTable] WHERE SOnumber= someVariable
UNION
VALUES ('Status_Pending')
ASKER
The above does not work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
INSERT INTO [salesOrderTable] (customerID, SOnumber, status)
SELECT customerID, SOnumber,'Status_Pending'
FROM [salesOrderTable]
WHERE SOnumber= someVariable
pipped at the post ;)
ASKER
I did that and it didn't work.........let me try again.
ASKER
Thank you guys.......I actually was using "status" instead of 'status'.
Dear All,
I have a similar problem to this, a novice thing really.
all I want to do is this...
Have a form whihc looks up for example a part code, and supplies the desc and rpice to the similarly named fields in the target table. I need the ability to alter the looked up info though, in the case of a slight alteration to the desc, or the price. so it's effectively a COPY DATA I'm after, not just a look up. Can I do this without code?
Regards
davesm@freeuk.com
I have a similar problem to this, a novice thing really.
all I want to do is this...
Have a form whihc looks up for example a part code, and supplies the desc and rpice to the similarly named fields in the target table. I need the ability to alter the looked up info though, in the case of a slight alteration to the desc, or the price. so it's effectively a COPY DATA I'm after, not just a look up. Can I do this without code?
Regards
davesm@freeuk.com
dave,
You really need to post a new question. Yours isn't the same.
Do you mean you want to create a new record which is a copy of an existing record but with a possible change?
You really need to post a new question. Yours isn't the same.
Do you mean you want to create a new record which is a copy of an existing record but with a possible change?
insert into someTable
select fieldA, fieldB, fieldC from yourTable
union
select top 1 'someValue','anotherValue'