Results 1 to 5 of 5

Thread: SQL query help needed

  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    10

    SQL query help needed

    I need to update a field in a table where two other fields meet certain criteria.

    i.e. as seen below I m trying to update Cost to £100 where the SeasonName is Low and the CategoryID is B1

    Here is what i have so far.

    UPDATE Cost

    SET Cost = 100

    WHERE (SeasonName = 'Low') & (CategoryID = 'B1')
    ;

    I realise I am updating the whole field column, how do i just update one specific cell matching the criteria specified

    Help would be very appreciated.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    What database are you using?

    Also I don't understand what you mean by

    I realise I am updating the whole field column, how do i just update one specific cell matching the criteria specified

    Sounds like you are updating Excel cell.

  3. #3
    Join Date
    Mar 2003
    Location
    UK
    Posts
    10
    Using MS Access

    I have a table and it contains data such as below.

    CatID SeasonID Cost

    A1 Low
    B1 High
    C1 Medium

    I need update the cost field depending on the criteria so if CatID is A1 and season is Low cost will = £100

    Does that explain it better?

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You are on the right track,

    How about

    UPDATE Cost
    SET Cost = 100
    WHERE SeasonID = 'Low'
    AND CatID = 'B1';


    Assuming table name is also Cost.

  5. #5
    Join Date
    Mar 2003
    Location
    UK
    Posts
    10
    YOU ABSOLUTE BEAUTY

    Nearly had it though, I had "&" instead of "AND"

    Thankyou very much skhanal

    No doubt i will be in touch again

Posting Permissions

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