DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Update table

  1. #1
    Join Date
    Jul 2007

    Question Update table

    I have 2 tables and update data from one table to another. need to update one or two filed only.

    inout.Execute "UPDATE Staff_test " _
    & "SET name = (select name from staff) where empno = '102' ;"

    while excute received the following error:

    Subquery returned more the 1 value. This is not permitted when the subquery follow =,!=,<, >= or when the subquery is used as an expression.

    if I use like:

    inout.Execute "UPDATE Staff_test " _
    & "SET name = (select name from staff where staff.empno = '102' ) ;"

    Then no error but it update all records not specified one.

    Can someone fix pls.

    Last edited by kafsar; 12-15-2010 at 06:20 AM.

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    You need to include the WHERE clause on both the main query and the subquery:

    UPDATE Staff_test
    SET name = (SELECT name FROM staff WHERE staff.empno = '102' )
    WHERE empno = '102';
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. SQL Insert data in Multiple table and Update at same time
    By software_develo in forum Database
    Replies: 10
    Last Post: 02-21-2012, 12:02 PM
  2. Text file update Access Table
    By charligov in forum VB Classic
    Replies: 2
    Last Post: 01-22-2007, 12:00 PM
  3. Problem with source table update
    By novi in forum Database
    Replies: 2
    Last Post: 03-09-2005, 12:56 PM
  4. update from record in same table
    By JeePee in forum Database
    Replies: 7
    Last Post: 02-18-2005, 02:42 PM
  5. Update on table by using stored procedure
    By Marian Stirbescu in forum VB Classic
    Replies: 0
    Last Post: 09-22-2001, 04:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center