Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    67

    Red face Unanswered: Updating and adding Data to database

    Hi,

    I want to add another column/field into an existing table (with obscene amount of data). This new column has to match or correspond with an existing field in table. For example, if the existing field is businesses, and for every business' name that starts with an "A" for example, there will be like the word "good" in the new column/field.

    I know I need to create a query, what expression or criteria I have to enter that automatically updates or inputs the word "good" for every business' name starts with the letter "A" in the new field/column?

    Thx in advance,
    Michael

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try
    UPDATE yourTableName
    SET yourFieldName="Good"
    WHERE Mid(BusinessName,1,1) = "A";

  3. #3
    Join Date
    Nov 2006
    Posts
    67
    Thanks, that worked.

    How to combine 2 or more criteria?

    Like:
    Update Tb_sample
    Set platform="Good"
    Where Business = 'International Businesses' ;
    Where Products = 'High Quality' ;
    (how to I combine these 2 where statements?) I tried commas, and colons...didn't work.

    Thanks in advance,
    michael

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by tialongz
    Thanks, that worked.

    How to combine 2 or more criteria?

    Like:
    Update Tb_sample
    Set platform="Good"
    Where Business = 'International Businesses' ;
    Where Products = 'High Quality' ;
    (how to I combine these 2 where statements?) I tried commas, and colons...didn't work.

    Thanks in advance,
    michael
    Use the AND operator

    UPDATE Tb_sample
    SET platform="Good"
    WHERE Business = 'International Businesses' AND Products = 'High Quality' ;


  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Advice:
    It is better to use keys for your Text i.e
    Put International Businesses and High Quality in a table and give it a key

    PHP Code:
    ID          Description

    100        International Businesses  
    110        High Quality
    120        Bad Quality
    ---         ------------
    ---         ------------ 
    Then combine the key table with your table and make the update

Posting Permissions

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