Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:56:56+00:00 2026-06-17T17:56:56+00:00

I am new in Mysql . I want to add a column in table

  • 0

I am new in Mysql . I want to add a column in table with value depending another column value in the same table. For example I have company_table as below :

fldId | companyName | date
--------------------------------
  1   | adeco       | 2012-01-12    
  2   | mic         | 2001-03-09
  3   | manpower    | Null
  4   | linar       | Null
  5   | dlank       | 1999-02-28

I want to add ‘fldState’ column in this table depending on value of ‘date’ column. For example if value of ‘date’ column is not Null then value of ‘fldState’ should be 1 and if it’s Null then value of ‘fldState’ should be 2. like below

  fldId | companyName | date        | fldState
  --------------------------------------------
  1     | adeco       | 2012-01-12  | 1
  2     | mic         | 2001-03-09  | 1 
  3     | manpower    | Null        | 2
  4     | linar       | Null        | 2
  5     | dlank       | 1999-02-28  | 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:56:57+00:00Added an answer on June 17, 2026 at 5:56 pm

    From your existing table, you need to create an ALTER statement so that you can add new column.

    ALTER TABLE mytableName ADD fldState INT;
    
    • Adding New Column from a table

    After the statement has been successfully executed, you can now update all the records,

    UPDATE  myTableName
    SET     fldState = IF(date IS NULL, 2, 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a new column to an existing mysql table, where the
I want to create a new column in a MYSQL table that has Fn
Can we create a new MySQL database( not a table, I want a new
I want to add a new item (Cheese) to an sqlite table but only
So i have MySql and i have a table user with a user_id column
I have a mysql table in which there is a column e.g. called name.
I want to load an xml file into a table column with MySQL. How
I created a new mysql database and i want to use foreign keys with
Im new to MySql, and I need to insert into table 10000 random 2-digit
I am new to MySQL, but I have used Oracle for some time. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.