Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001

    Unanswered: Need help in updating a table

    2 questions:

    How do you update a field in a table (using VB) where several
    records meet the criteria but you want it to update the first record
    and not all.

    eg. in Table1 are the following records:
    name amount invno.
    ABC $200.00 123
    DEF $100.00 0
    DEF $100.00 0

    I want to be able to update the inv no. for the first record whose
    name is DEF

    What is the syntax for updating a field in a table where the default value is set to zero. I want to say 'where the invno = 0' (invno is a number field in the table)

    Will appreciate any help

  2. #2
    Join Date
    Apr 2002

    UPDATE Table1 SET InvNo = a_nice_number
    WHERE MyPrimaryKey = (
    SELECT first(MyPrimaryKey) FROM Table1
    WHERE Name = 'DEF' ORDER BY some_order);

    This will update the first record matching the Name DEF in the order of some_order with a_nice_number.


    Not sure if I really get what you mean. But when you just want to update all records with an invoice number or 0 this should do it:

    UPDATE someTable SET some_field = some_value
    WHERE InvNo = 0;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts