Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
i want query for inserting two input parameters and remaining fields from other table in single query.
example :
INSERT INTO Members ( memberName, userID)
VALUES('MYNAME', (SELECT userID FROM USERS WHERE userUNIQUEID = '123'));
i need to insert a row into member table.
i want to pass 'MYNAME' as parameter and UserId will be from select statement.
can any one please give me correct syntax of the query.
This should work:
Add as many constants to the SELECT clause as you need (number of values in the SELECT clause must match the number of columns being inserted, of course).
Two notes:
Is userUNIQUEID really a VARCHAR? If it is a NUMBER, you should use 123 and not '123'.
If you plan to run this statement from Java, use PreparedStatement and replace literal values with binds.
hi thank you for the reply.
that was a example query.
i have found the solution
i need to give my parameter value in select clause.
INSERT INTO Members ( userID,memberName) SELECT userID,'MYNAME' FROM USERS WHERE userUNIQUEID = '123';
thank you.
Sudheer SCWCD, SCJP 5
You get good luck from rubbing the belly of a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth