Web Analytics Made Easy -
StatCounter Deleting an entire enry of data? - CodingForum

Announcement

Collapse
No announcement yet.

Deleting an entire enry of data?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deleting an entire enry of data?

    I have this table:
    +------+---------------+------------+
    | id | primarycolour | pricerange |
    +------+---------------+------------+
    | 1 | black | 1 |
    | NULL | brown | 2 |
    +------+---------------+------------+
    I want to delete the entire entry for NULL. I tried this, but it didn't work:
    Code:
    delete from testdb.products where id='NULL';
    How can it be done?

    Also, I don't think saying "deleting an entire entry of data" is correct. Is what I am asking to do is to delete a primary key?

  • #2
    You are deleting a row of data. What you tried will not work because it is comparing the string NULL to a NULL value which is different. If you id column is indeed a primary key column it should not be able to be null FWIW.

    Code:
    DELETE FROM `products` WHERE `id` = NULL
    Dave .... HostMonster for all of your hosting needs

    Comment


    • #3
      I tried the code, but it didn't work.

      Comment


      • #4
        Sorry, syntax slightly off for a column that is null.

        Code:
        DELETE FROM `products` WHERE `id` IS NULL
        Dave .... HostMonster for all of your hosting needs

        Comment


        • #5
          It worked!!!!

          Thank you.

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎