The 'dafault' value question

Discussion in 'PHP' started by cancer10, Oct 10, 2007.

  1. #1
    Hello,

    If you have used phpmyadmin, you might have noticed while creating a table there are few optional fields asked by phpmyadmin along with the table name

    like

    tablename | Datatype | Length | Default etc etc


    Not my question is how do you make use of this Default field?

    I know it puts a value when inserting a data into the mysql database, but suppose I have a table with some values into it, can I restore the default value in my table with the current values?

    if yes how?



    Plz Help,

    Thanx
     
    cancer10, Oct 10, 2007 IP
  2. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    default value is inserted to your table when you do an insert query without specifying the field.

    let say you have fields : name and address
    and you have default value of "john" for your name.

    when you do insert into table_name set address = "lake idaho"
    your tables will be populated with a row containing "john" on the `name` field and "lake idaho" on the address field.

    when you do insert into table_name set address = "lake idaho", name = "jake"
    your tables will be populated with a row containing "jake" on the `name` field and "lake idaho" on the address field.

    does this answer your question? pardon my english please.
     
    kendo1979, Oct 10, 2007 IP