How do i get the NULL value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajiv07
    New Member
    • Jun 2007
    • 141

    How do i get the NULL value

    Hi to all

    I have an doubt on getting NULL value from mysql tables. If i fetch the null values it return empty string,Bt i want to get the NULL value as it is.

    Please Help on this.

    Regards
    Rajiv
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by rajiv07
    Hi to all

    I have an doubt on getting NULL value from mysql tables. If i fetch the null values it return empty string,Bt i want to get the NULL value as it is.

    Please Help on this.

    Regards
    Rajiv
    Try this query:

    [code=mysql]

    SELECT IFNULL(column1, 'NULL') FROM table1;

    [/code]

    Comment

    • rajiv07
      New Member
      • Jun 2007
      • 141

      #3
      Originally posted by amitpatel66
      Try this query:

      [code=mysql]

      SELECT IFNULL(column1, 'NULL') FROM table1;

      [/code]
      Thank you Amit,

      Its working fine

      Comment

      • rajiv07
        New Member
        • Jun 2007
        • 141

        #4
        Hai to all

        I have one more doubt on this NULL value.If i select a row from table if the row has null value It should return NULL instead of empty string.

        Suppose an example row

        Rajiv -- gandhi -- NULL -- NULL

        when i try to fetch this row it return as it is.

        Please help on this

        Regards
        Rajiv

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Show your select statement and we will see how you can adapt that.

          Ronald

          Comment

          • rajiv07
            New Member
            • Jun 2007
            • 141

            #6
            Originally posted by ronverdonk
            Show your select statement and we will see how you can adapt that.

            Ronald
            Thank you ronverdonk,

            Actually i am doing export database program in perl language for that i am trying to get row values as it is.

            EX.

            Table name rajiv

            rajiv---gandhi---16--- NULL--- NULL

            Generally i am using [CODE=mysql]select * from rajiv[/CODE] to select the table row but it will return all null value in to empty string but i want the NULL value as it is.

            Regards
            Rajiv

            Comment

            • amitpatel66
              Recognized Expert Top Contributor
              • Mar 2007
              • 2358

              #7
              Originally posted by rajiv07
              Thank you ronverdonk,

              Actually i am doing export database program in perl language for that i am trying to get row values as it is.

              EX.

              Table name rajiv

              rajiv---gandhi---16--- NULL--- NULL

              Generally i am using [CODE=mysql]select * from rajiv[/CODE] to select the table row but it will return all null value in to empty string but i want the NULL value as it is.

              Regards
              Rajiv
              In that case, select all the columns in your query instead of using an "*":

              [code=mysql]

              SELECT first_name,last _name, age, IFNULL(DOB, 'NULL'),IFNULL( col6,'NULL') FROM rajiv

              [/code]

              Comment

              Working...