Null Values in a table not properly selected

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Null Values in a table not properly selected

    I am using SQL Server 7.0. I have a table with a field called PARENT_ID,
    which has a numerical value entered for those which have a logical parent,
    and has an empty value for those that do not. I want to select the records
    which have a PARENT_ID = '' (Parent_ID equal to nothing). The following
    code, however, returns an empty set of results. Could somebody please point
    out where the error lies in the code?

    SELECT LOC_NAME, LOC_ID, PARENT_ID FROM SYS_LOCATIONS WHERE PARENT_ID = ''

    I've also tried:

    SELECT LOC_NAME, LOC_ID, PARENT_ID FROM SYS_LOCATIONS WHERE PARENT_ID = Null

    Neither appear to be working correctly. Any help would be appreciated.

    Thanks,
    Jacob


    Jacob Guest

  2. Similar Questions and Discussions

    1. #26288 [Opn->Fbk]: Segmentation Fault while getting NULL values from a row of a table
      ID: 26288 Updated by: iliaa@php.net Reported By: kiranhariharan at in dot ibm dot com -Status: Open +Status: ...
    2. #26288 [Opn]: Segmentation Fault while getting NULL values from a row of a table
      ID: 26288 User updated by: kiranhariharan at in dot ibm dot com Reported By: kiranhariharan at in dot ibm dot com Status: ...
    3. #26288 [Fbk->Opn]: Segmentation Fault while getting NULL values from a row of a table
      ID: 26288 User updated by: kiranhariharan at in dot ibm dot com -Summary: Segmentation Fault while getting NULL values from...
    4. #26288 [Opn->Fbk]: Segmentation Fault while getting NULL values from a row of a table(PHP v 4.2.2)
      ID: 26288 Updated by: iliaa@php.net Reported By: kiranhariharan at in dot ibm dot com -Status: Open +Status: ...
    5. Finding null values in a large table
      I have a fairly large table (millions of rows) and I would like to be able to find rows that have a null value in a particular column. I know that...
  3. #2

    Default Re: Null Values in a table not properly selected

    What is the data type of parent_id? If it is numeric, then 0 is the value
    when it is not set.

    might also try

    WHERE (PARENT_ID & '') = ''

    This will handle the null or zero length values for PARENT_ID


    "Jacob" <yak2016@comcast.net> wrote in message
    news:%23am1fkwQDHA.2676@TK2MSFTNGP10.phx.gbl...
    > I am using SQL Server 7.0. I have a table with a field called PARENT_ID,
    > which has a numerical value entered for those which have a logical parent,
    > and has an empty value for those that do not. I want to select the
    records
    > which have a PARENT_ID = '' (Parent_ID equal to nothing). The following
    > code, however, returns an empty set of results. Could somebody please
    point
    > out where the error lies in the code?
    >
    > SELECT LOC_NAME, LOC_ID, PARENT_ID FROM SYS_LOCATIONS WHERE PARENT_ID = ''
    >
    > I've also tried:
    >
    > SELECT LOC_NAME, LOC_ID, PARENT_ID FROM SYS_LOCATIONS WHERE PARENT_ID =
    Null
    >
    > Neither appear to be working correctly. Any help would be appreciated.
    >
    > Thanks,
    > Jacob
    >
    >

    Marvin Thompson Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139