• 0

Phpmyadmin query help (null)


Question

I need to enter quite a lot of entries into phpmyadmin using the following format

insert into databasetable values('','19','firstname','lastname','1111','0','0','0','0','1','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','NULL','0','NULL','NULL')

The problem is, null is not working. They are going into the database as 0, is there any way to correct this? The columns are set to default to null

Link to comment
https://www.neowin.net/forum/topic/1201577-phpmyadmin-query-help-null/
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hello,

What database is this?

What datatype do the columns have?

Also I highly recommend, to avoid entering a "NULL" into a string and other common mistakes

insert into person(name,age,sex) values ("John",16,"Male");
  • Like 2
  • 0

Hello,

  On 20/02/2014 at 12:17, marklcfc said:

Thanks, that worked very well when I changed to your setup and just inserted the values I needed to.

Yeah, its something that usually happens. You miss/put a extra "'" or "," and you mess up. The string I wrote make it 100% sure you are inserting the values you want in the exact columns you want.

Please mark my answer as solved :) Thank you

  • 0

Hello,

  On 20/02/2014 at 23:46, Fahim S. said:

NULL is a reserved keyword in SQL. The error in your statement is that you have put quotes around NULL.

Some automatically convert "NULL" into NULL, if Im not mistaken (depends on datatype column and the program you use).

Correct me if Im wrong Fahim S. I usually don't use NULLs

  • 0
  On 21/02/2014 at 09:39, riahc3 said:

Hello,

Some automatically convert "NULL" into NULL, if Im not mistaken (depends on datatype column and the program you use).

Correct me if Im wrong Fahim S. I usually don't use NULLs

 

I just did a quick test in MySQL, only database engine I have readily available right now.

 

I created a table (nulltest1) with the three nullable columns:

1) column1 varchar(4)

2) column2 interger

3) column3 decimal

 

I then tried running the insert statement:

insert into nulltest1 values ("NULL", "NULL", "NULL");

This inserted the values: NULL (the string NULL), 0, 0.

 

When I ran the queries:

select * from nulltest1 where column1 is null;
select * from nulltest1 where column2 is null;
select * from nulltest1 where column3 is null;

Each returned 0 results.

 

When I ran the query:

insert into nulltest1 values (NULL, NULL, NULL);
 

I then tried running the same three select statements:

select * from nulltest1 where column1 is null;
select * from nulltest1 where column2 is null;
select * from nulltest1 where column3 is null;

each returned 1 row.

 

This says that despite the engine doing conversion of the string to a value appropriate to an integer or a decimal, it is not the same thing as NULL.

I have to say it surprised me that the engine does this conversion - I would have expected an error on the insert statement.

  • 0

Hello,

  On 21/02/2014 at 14:07, Fahim S. said:

I just did a quick test in MySQL, only database engine I have readily available right now.

 

I created a table (nulltest1) with the three nullable columns:

1) column1 varchar(4)

2) column2 interger

3) column3 decimal

 

I then tried running the insert statement:

insert into nulltest1 values ("NULL", "NULL", "NULL");
This inserted the values: NULL (the string NULL), 0, 0.

 

When I ran the queries:

select * from nulltest1 where column1 is null;
select * from nulltest1 where column2 is null;
select * from nulltest1 where column3 is null;
Each returned 0 results.

 

When I ran the query:

insert into nulltest1 values (NULL, NULL, NULL);
 

I then tried running the same three select statements:

select * from nulltest1 where column1 is null;
select * from nulltest1 where column2 is null;
select * from nulltest1 where column3 is null;
each returned 1 row.

 

This says that despite the engine doing conversion of the string to a value appropriate to an integer or a decimal, it is not the same thing as NULL.

I have to say it surprised me that the engine does this conversion - I would have expected an error on the insert statement.

Thank you for testing it out :laugh: I didnt even look it up.

Needthless to say, Im sure you recommend that never count on engine conversions; They can have some ugly side effects that can drive you mad.

  On 21/02/2014 at 16:09, vhane said:

"NULL" is not NULL. The latter denotes the absence of data in SQL.

NULL is one of the worst inventions ever of databasing. And when you mix programs using datasources, it makes it worst :no:

One of the many reasons I never use NULL

  • 0
  On 21/02/2014 at 16:09, vhane said:

"NULL" is not NULL. The latter denotes the absence of data in SQL.

 

Exactly.

 

  On 21/02/2014 at 16:15, riahc3 said:

NULL is one of the worst inventions ever of databasing. And when you mix programs using datasources, it makes it worst :no:

One of the many reasons I never use NULL

NULL is an important part of modern day RDBMS - to say that you never use it is to prevent yourself that important part.

 

I cannot understand why you wouldn't use it.  Anyone who is dealing with databases properly can't avoid it without employing some horrible hacks to achieve the same result.  You should therefore use it and learn how to use it properly.

  • 0

Hello,

  On 21/02/2014 at 16:35, Fahim S. said:

I cannot understand why you wouldn't use it.  Anyone who is dealing with databases properly can't avoid it without employing some horrible hacks to achieve the same result.  You should therefore use it and learn how to use it properly.

Im speaking from my point of view.

Web app that basically loads client's information and loads names of items and such from DB.

When, for example, a client's phone number isnt avaliable I just put 0. If I dont know his second last name, I just put "". NULL really serves no purpose as everything is basically "yes" or "no", not "yes" "no" "unknown" which is what NULL's purpose is.

As a joke, just that NULL is allowed as a type in Java, worst language ever, shows how crappy it is :laugh:

BTW, we can have a huge argument about this so Fahim reply if you want, but I wont continue.

  • 0
  On 21/02/2014 at 16:49, riahc3 said:

Hello,

Im speaking from my point of view.

Web app that basically loads client's information and loads names of items and such from DB.

When, for example, a client's phone number isnt avaliable I just put 0. If I dont know his second last name, I just put "". NULL really serves no purpose as everything is basically "yes" or "no", not "yes" "no" "unknown" which is what NULL's purpose is.

As a joke, just that NULL is allowed as a type in Java, worst language ever, shows how crappy it is :laugh:

BTW, we can have a huge argument about this so Fahim reply if you want, but I wont continue.

 

I'm interested...  I'm not arguing, just interested.

 

what do you do where "" is a valid value and you need to support a not supplied value?

 

The Java language itself isn't actually that bad - actually arguably the purest object oriented language out there.  The platform itself could be far better - you need to ensure you aren't confusing the two.

 

null isn't a type in Java, it is a value of a variable that doesn't reference an actual object.

Setting something null in Java is used to tell the runtime that part of the heap is ready for garbage collection and allows some control of memory management.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Chinese? It sounds extremely dangerous. I’ll reconsider buying a Meta Quest 3.
    • - What's your salary? Is it more than $100k a year? - Nah, it's $100 mil a year.
    • Compared to my ear buds which are the size of a matchbox, cover a much broader frequency range, and work everywhere without setup? Yeah, still not buying this as a replacement.
    • Meta's Superintelligence team staffed by 50% Chinese talent, 40% ex-OpenAI by Hamid Ganji Mark Zuckerberg's latest big bet at Meta involves building a team of the best AI superstars in the market to lead the so-called Superintelligence Labs. The goal of this team is to develop AI models that will ultimately lead to Artificial General Intelligence (AGI). AGI refers to an AI model with capabilities comparable to, or even beyond, those of the human brain. Achieving human-level cognitive abilities with an AI model requires substantial investments, as well as hiring the best talent to build such a system. That's why Meta is throwing hundreds of millions of dollars at AI researchers from OpenAI, Apple, and other companies to recruit them for its Superintelligence team. A user on X has now shared a spreadsheet that provides us with some unique insights into Meta's Superintelligence team and the origins of its 44 employees. The leaker claims this information comes from an anonymous Meta employee. The listing claims that 50 percent of the staff at the Superintelligence team are from China, which demonstrates the significant role of Chinese or Chinese-origin researchers in Met's AI efforts. Additionally, 75 percent of these staff hold PhDs, and 70 percent of them work as researchers. Interestingly, 40 percent of the staff are ex-OpenAI employees whom Mark Zuckerberg poached from the maker of ChatGPT. Additionally, 20 percent of Meta's Superintelligence team members come from Google DeepMind, and another 15 percent come from Scale AI, a startup that Meta recently acquired in a $15 billion deal. Another interesting point is that 75 percent of the Superintelligence team are first-generation immigrants. The leaker claims that each of these employees is now earning between $10 million and $100 million per year, although Meta still needs to confirm these substantial figures. However, it has already been reported that Meta is offering up to $100 million in signup bonuses to poach the best AI talent from OpenAI and other rivals. The revelation that half of Meta's Superintelligence team consists of Chinese nationals could trigger concerns within the Trump administration and Congress.
    • From a quick Google it seems 6GHz is optional on 802.11be. Ubiquiti has one, Unifi U7 Lite.
  • Recent Achievements

    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      207
    3. 3
      Michael Scrip
      206
    4. 4
      Xenon
      138
    5. 5
      +FloatingFatMan
      113
  • Tell a friend

    Love Neowin? Tell a friend!