Link to home
Start Free TrialLog in
Avatar of ki_ki
ki_kiFlag for United States of America

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
Avatar of heer2351
heer2351

I think you can use a union query, not tested though:

insert into someTable
select fieldA, fieldB, fieldC from yourTable
union
select top 1 'someValue','anotherValue',10 from yourTable

Avatar of ki_ki

ASKER

You mean? --->
INSERT INTO [salesOrderTable] (customerID, SOnumber, status)
SELECT (customerID, SOnumber) FROM  [salesOrderTable] WHERE SOnumber= someVariable
UNION
VALUES ('Status_Pending')
Avatar of ki_ki

ASKER

The above does not work.
ASKER CERTIFIED SOLUTION
Avatar of heer2351
heer2351

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

INSERT INTO [salesOrderTable] (customerID, SOnumber, status)
SELECT customerID, SOnumber,'Status_Pending'  
FROM  [salesOrderTable]
WHERE SOnumber= someVariable

pipped at the post ;)
Avatar of ki_ki

ASKER

I did that and it didn't work.........let me try again.
Avatar of ki_ki

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
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?