Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





MySQL 4.0.17 Data Scrambles, Not-null Fields Become Null, Etc.


I'm having the most bizarre problem with PHP/MySQL that I've ever
faced and it's an urgent matter (of course) to try to fix it ASAP.

We have one record inserted into a table with 75 columns, whereby half
of the columns are not-null, but for some bizarre reason, the fields
are null. The rest of the columns that are null are completely
scrambled (e.g. "first_name" is in "address2", "fax" is in "url", "url"
is in "last_name", etc.)

This just recently occurred and seems to have no history otherwise. It
occurred sometime on Saturday when the record was inserted but logs
indicate no unusual activity at that time.

Has anyone seen this before and found a way to prevent it from
occurring again?




View Complete Forum Thread with Replies

Related Forum Messages:
Load Data Infile And NULL Fields
I am trying to load a a large data fille (half a million records). Currently it is a text file, tab delimited. I have some fields in it that are numeric, nullable. In the text file when a row has a null in this field, it basically shows up as back-to-back tabs with nothing in between them.

I have text fields that are the same, but the first time I get an error (on row 1 which has a number of these nulls) it is on a numeric field.

How can I tell MySQL to interpret back-to-back tabs as tab NULL tab and put nulls in the right columns? Does text vs integer matter in the table definition? It is the fact that it falls apart on a numeric field coincidence?

(The exact error is 1264 - Out of range value adjusted for column 'hbem3' at row 1).

View Replies !
Search For Null (or Empty) Fields And Replace With Data
So if data exists in MySQL I can use
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

and that works fine.

but if
'[string_to_find]'
is empty or NULL
it doesn't work

View Replies !
Troubles Into Importing Data Into Tables With Not Null Fields/keys
I have created a table with some fields set as "not null" and one like record key.

The problem I have is that when I try to import data into the table from a txt file using the command "LOAD DATA INFILE..." it is importing "wrong" or "incomplete" records too

My source data is not always correct and some necessary fields could be not available in the text file.

I was supposing that when a table key value was missing or a null value was entered in a not null field, the entire record should be skipped but it is not so: I can see records where the key is missing or where not null fields are inserted like null.

View Replies !
Incorrect Integer Value: 'NULL' For Column Even If NULL Is Allowed
mysql> desc my_table;
+------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| id | varchar(19) | NO | PRI | | |
| value1 | int(11) | YES | | NULL | |
| value2 | int(11) | YES | | NULL | |
+------------+---------------------+------+-----+---------+-------+

I want to import data from a file that looks like this:
9bcd6f7b47a30fb8_01;NULL;NULL

With following command:
mysql> load data infile 'filename' into table my_table fields terminated by ';';

And get following error:
ERROR 1366 (HY000): Incorrect integer value: 'NULL' for column value1'' at row 1

So the system denies me importing NULL values into a field where NULL is allowed.

View Replies !
Is Null Clause Takes A Lot Of Time But Is Not Null Statement Not
i have a query which takes 1 and half minute to fully execute. This query is following which return 2 records

select o.id, o.number, o.timest, o.receiptno, o.canedit, o.sessionid, o.voidorder, o.cashchange,p.amount from orders o left join payments p on (o.id=p.oid) where p.amount is null

but if i remove the 'not' from where clause then it takes a fraction of seconds. query is following which takes fraction of second and it returns 3920 records

select o.id, o.number, o.timest, o.receiptno, o.canedit, o.sessionid, o.voidorder, o.cashchange,p.amount from orders o left join payments p on (o.id=p.oid) where p.amount is not null

View Replies !
Autofill NULL Fields
i have a problem that hopefully mysql can solve. I have 5 fields and i want them to be auto filled. The fields are null until they are filled but i need an easy way to slowly fill the first field first, then the 2nd, then the third, then the 4th, and finally the 5th.

See i don't know which fields are null so i can do the insert. So something like this,

$SQL = $connection->prepare("INSERT INTO `tablename` AUTOFILL(fieldname1, fieldname2, fieldname3, fieldname4, fieldname5);

if fieldname1 is not null, it inserts into fieldname2; if fieldname2 is not null it inserts into fieldname3

View Replies !
Two Fields Make Null
I am trying to figure out the best way to do this. I am searching for info in two fields. Now there maybe a row with info in one field and the info in another row in another field. But not the same info in the same row wll return null.
PHP Code:

SELECT * WHERE  `cust_name` LIKE "%info%" AND `information` LIKE "%info%" 

So in other words it might find the info in the 'cust_name' in one row and info in the 'information' on another row. What I would basically want to do is an OR in stead of AND.

View Replies !
Is It Possible Outfile Without Null Fields?
I would like my end oufile to not have /N or NULL in fields that are null or to have a query that would filter out all the null fields before exporting.

View Replies !
Retrieving Fields With A Null Value
i'm trying to write this query which is looking for fields that are NULL, but it doesn't seem to work. What's wrong with this code snippet.

I checked my database and the fields are in fact NULL so i know the problem is within this code.


$query = "SELECT `jid`, `jobnumber`, `jobname`, `install_date` FROM `jobs` WHERE `engineering_received` = 'NULL' OR `engineering_received` = '' ORDER BY install_date";

View Replies !
Getting Null Values From A TEXT NOT NULL Field
I have created a table with a field labeled Description which is a TEXT field which does not allow null values. It's defined with

Description TEXT NOT NULL,

However, when empty strings are stored in the Description field, I get NULLs back when querying the database. I'm writing an ASP application which connects to the MySQL database through ADODB. The MySQL version is 5.0.45. The engine is InnoDB.

View Replies !
NOT NULL Fields In INNODB Tables
My database is composed of INNODB tables such as...

CREATE TABLEuser
(
nameVARCHAR(255)NOT NULL

) TYPE = INNODB;

The NOT NULL qualifier doesn't work as I would expect. While it
doesn't allow me to do this:

insert user values (null);

It will let me do this:

insert user values ("");

I appreciate that one could argue that "" is different to NULL and
therefore there is nothing wrong with this behaviour. However, surely
there is no defending the following (which is also allowed):

update user set name=NULL;

Is there any way that I can prevent users from setting a field to NULL
or ""? I am running version 4.0.17-nt on Windows XP

View Replies !
How To Select All The Fields In Aparticular Row That IS NULL
I want to select fields which has null values in a particular row.

if there is one field i can give as

Select a,b,c from tablename where a IS NULL;

But my problem is

I want to get results from a,b and c not only from a.

View Replies !
Unique Index & Null Fields
I have a table with a particular field that needs to be unique and allow null values. According to the documentation:

"A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. This constraint does not apply to NULL values except for the BDB storage engine. For other engines, a UNIQUE index allows multiple NULL values for columns that can contain NULL."

... which is exactly what I want. Except that's not what I'm seeing in my database. When I try to insert more than one null value into this column, the database throws an error: ....

View Replies !
NULL Fields In CSV-output Query...
I'm trying create a query to export to a CSV file (using "SQL Manager 2007 for MySQL" query-builder).

The resulting CSV-file needs to be in a format where NULL fields are ignored (simply TAB to next field) rather than represented by the ESCAPEflag-N sequence ie: N.

Is there a modifier for the SELECT statement that would allow me to specify how NULL fields are represented in the resulting text file? Something like NULL=""?

View Replies !
Null Fields Excluded In Search
I'm pulling my dropdown menu from a table. In my column "agent" some rows are null. When I am doing a search, no rows will show up where "agent" is null. Should I have something in the "value" that would include the null fields?

Here is my query:

"SELECT * FROM leadsDateView WHERE fullname LIKE '%$client%' and agent LIKE '%$agent%' ORDER BY `date` DESC";

Here is my dropdown option: .....

View Replies !
Check For NULL Fields In All Columns Of A Table
I am populating tables via programs and load data infile command, For my tables all the fields should not be null. James told me the syntax for checking null fields,

SELECT COUNT(*) FROM table WHERE col1 IS NULL;

This command is working for a single column only.How do I check for all the columns of my table in a single command.

View Replies !
CREATE TABLE :: Null And Not Null
I recently created a new table in a database and wanted some fields to accept nulls (NULL) and others to not accept nulls (NOT NULL). The table was built correctly, however, when I went to edit a row in the Query Window of MySQL Browser it allowed me to enter in the row when the NOT NULL fields had no values attached to them - this should fail and stop me from entering a row.

Here is the script for the table I created;

CREATE TABLE SLG (
SLG_ID int(11) NOT NULL auto_increment,
SLG_CODE CHAR(1) NOT NULL,
SLG_DESCRIPTION VARCHAR(255) NOT NULL,
SLG_DATE_CREATED DATETIME NOT NULL,
SLG_DATE_MODIFIED DATETIME NOT NULL,
PRIMARY KEY (SLG_ID)
);

When I apply the changes in this window it just enters NULLS into all the other fields. Is this a Query Browser issue. I tried doing the same with an INSERT statement and received the same result.

Also - related to creating a table - is it possible to create global Defaults on a database and then reference those in the DEFAULT statement of the CREATE TABLE command. MS SQL has a system function that can be executed after a table is created to bind a global default to a specific column.

View Replies !
Insert Null To Not Null Column
I have build a replication environment in my environment. the master is MySQL 5.0.24a-standard-log and the slave is 5.1.30-log. the configuration is not the same between them.

I have found a replicaiton error in the slave today says: .....

View Replies !
Null And The Text Data Type
Why do we use null values? Why is it better than an empty field?
What would be a real life situation were nulls are important to have?
If I have a paragraph of text in a field of data type: TEXT. Can I
search in this field? Maybe i mean, could i use SELECT on a table
and get rows on the basis of a string or substring in the TEXT field?

View Replies !
Null Field Not Taking Data
I have a mysql table with a password field. (varchar(20), Null YES). When i input data into the field from the form, I look at the table and it say null. It's not taking the data that I input into it.

View Replies !
Select Field With NULL Data
check this out:
mysql> select price, price_increase from l_foods;
+-------+----------------+
| price | price_increase |
+-------+----------------+
| 2.64 | 0.25 |
| 1.94 | NULL |
| 4.67 | 0.40 |
| 7.94 | 0.70 |
| 3.35 | 0.30 |
| 1.32 | 0.05 |
| 1.94 | NULL |
| 1.68 | 0.25 |
| 1.15 | 0.15 |
| 3.97 | 0.50 |
+-------+----------------+
10 rows in set (0.01 sec)

I am tryingto select price for food item that does not have price_increase.
i tried something like
select price_description from l_food where price_increase = NULL;

but it gives me empty set.
what do i put for price_increase if it is null?

View Replies !
Loading Data & Null Columns
Having used Oracle's SQL*Ldr for over a decade now, I'm puzzled about the treatment of null values when using mysql's LOAD DATA INFILE syntax. This is the describe of the table being loaded: Code:

View Replies !
Fill Up NULL Data With Data Whose ID Is Equal
I have this table

id name
-----------
1 Daniel
1 NULL
2 Marc
1 NULL
2 NULL

and I need this one

id name
-----------
1 Daniel
1 Daniel
2 Marc
1 Daniel
2 Marc

View Replies !
Load Data Infile Creates 0 Instead Of Null
I am writing a Java program to populate the MySQL table xml_items. It needs to load data from a CSV (comma delimited) file. The load of the data works great when I run it except for one excpeiont. The column parent_reference_key may contain nulls or may be filled in a with a numeric value. In the file the field will either be referenced with nothing between the commans (,,) or with a numeric between the commas (,13,). For the records on the file that have nothing between the commans the database is defaulting the value to zero (0) instead of null, like it should be. For thet able setup on the database I have the default value as null. I also receive an exception message when I try to load this file:

Upload SQLException # 5: Data truncation: Data truncated for column 'parent_reference_key' at row 1

which is related to the record(s) that have nothing between the commas.

LOAD DATA INFILE '" + filePath + "' INTO TABLE xml_items
FIELDS TERMINATED BY ',' " + "(pk, name, parent_reference_key,
parent_name, data_type, xml_type, source_id, source_name);

If the column will not default to a null value with there is nothing placed between the commas of the load file then what option do I have to load this file and create null values for that column?

View Replies !
Loading Data Results In NULL Rows??
I am using LOAD DATA very simply but it is resulting in all the rows being NULL and I can't understand why.

Here is what I'm doing:
LOAD DATA INFILE '/var/www/Data/testfile.csv'
INTO TABLE trial.testdb
FIELDS TERMINATED BY '¿'
LINES TERMINATED BY '
'
IGNORE 2 LINES;

The command runs successful but when I check the data, the first column which is a date field, comes up at 0000-00-00 and all other columns are loaded as NULL.

Any clues on why this is happening? The # of columns in the file match up with what's in my table.

View Replies !
LOAD DATA INFILE And NULL Value Number
I use LOAD DATA INFILE command to load data from txt file to table that has some INT, DECIMAL type columns and all allow null value. IF data in text file is null (empty) or use null text (NULL), I got 'ERROR 1366 (HY000): Incorrect value ", if I set them to 0 for INT or 0.0 for DECIMAL, it works. I can run insert/update SQL statement to set null value to NULL.

Should I use some option in LOAD DATA INFILE command?

View Replies !
NULL And NOT NULL Settings
I have a MySQL table that stores name and age of a person. The name field needs to have a value; the age field is optional.I'm quite confused now with the NULL and NOT NULL settings... It seems that neither one does what I want (rejecting an INSERT query where the name field is empty)...So what exactly do I have to do?

View Replies !
VARCHAR Null/Not Null
I'm having a problem with a table that is already created - I want insert attempts to FAIL when the column for 'firstname' is empty (a VARCHAR field). Currently, the column is set to Null=YES and a Default of 'NULL'. This allows records to be inserted with no 'firstname' value (NULL appears in the column). If I change it in phpmyadmin 'structure' to Null=NO and Default of [empty field] then it allows records to be inserted with no 'firstname', and 'firstname' shows empty in the column

View Replies !
PK Field Not Null Is Being Null
I m newbie. I made a MySQL database table and in the primary key field I set the data type VAR CHAR.I also set it not null .BUT still I can insert blank values in this PRIMARY KEY field. If I just blank my primary key field by this query- Insert Tablename Values ('','','','','',''); (if my table has 6 fields).HOW IS IT POSSIBLE. How can PK field allow blank value when I set not null. HOW TO SOLVE IT.

2. I use a MySQL GUI Tools from http://dev.mysql.com/downloads/. In Table viewer of Query browser, each time I insert the first field, it sets the datatype to INTEGER,NOT NULL, AUTO INCREMENT. But I change it to VARCHAR as needed. Do I have to/should use Integer type in PK field and can Varchar be incremented.

3.Can I set user privilege to a particular row (on a particular PK); HOW?

4. Is it correct/incorrect that the name of the foreign key has to be the same as the name of the corresponding PK. I saw that in MySQL I can easily change the FK name to anything else and then just make a reference of FK to the PK.

5. How can I make a one-to-one relationship in MySQL;

View Replies !
Setting Null To Not Null How?
i have a mysql table.. (duh!)

a field in it is set to null and i want to unset it to make it not null.

how do i do that ? by default it takes null values (its weird.. default is null while null column is a no.. so it cant take null values!)

View Replies !
Importing Null Columns In CSV Data (Error 1366)
I am trying to import data from a CSV file using the LOAD DATA command. All is going well except for one file where some values are "empty". The data looks like this:

Customer Id,Username,Provider,DN,Gateway,Domain Name,Build Status,CPE Type
,,,09999999999,09999999999_CEASED_20070816175503,T.VKPT4VU4UDSRVF26MRB2PG8SLX,CS,220VB

As you can see, the first 3 columns are empty and when I import I get the error 1366 and the message: Incorrect integer value: '' for column 'customer_id' at row 1

I have set the table to allow NULL values and for the default value to be NULL for these columns, yet I still get this error message.

Please note that the data I am importing is exported from another system and therefore cannot be changed. The SQL I am running is: Code:

View Replies !
LOAD DATA INFILE Error Due To Null Values
I'm loading a data file which contains lots of null values. Am using /N which works well for all fields except for those of Type char(1). Does anyone know a way to add a null value to this type of data?

View Replies !
MySQL Null Values
I want to return all rows that have NULL in a certain column. I'm using this:

"SELECT * FROM myTable WHERE myDateTimeField = NULL"

I can use an INSERT or UPDATE queary with NULL to set the myDateTimeField to NULL, and I can use the "<>" operand to get all rows that are not NULL, like this:

"SELECT * FROM myTable WHERE myDateTimeField <> NULL"

But, that first statement always returns nothing, even though I know there are results for it being NULL...

View Replies !
Null Characters In Mysql Log File
we have noticed that our log files are enormous in size prior to compression (most recent is 2.5 gigs) and that these log files seem to contain a great deal of null () characters in set locations throughout. We are running Debian stable with a locally compiled and installed mysql 4.0.16-2. The nulls appear in the following manner in the logs:

View Replies !
Leave A Foreign Key Null In MySQL
I need to leave a field null, but i also need that field have a foreign key. But even after creating this table with the field with not "not-null", if i add the foreign key, i can't leave it blank (NULL).I'm using mysql 4.0.20a and all my tables as set to InnoDB.

View Replies !
MySQL Query For All Records With NULL Value
I have recently been trying to extract a few products from a database (that is quite big), so that I can find products that have a specific NULL Value, what kind of a SQL statement would allow me to do this?

View Replies !
Recent Mysql Upgrade, Ignores NOT NULL Declarations?
Can anyone tell me why CREATE TABLE and ALTER TABLE ignore the NOT NULL clause on my mysql 5.0.19 on windows xp?

This is problematic because I want to migrate some data to a older version who's NOT NULL fields are behaving as I would expect them to triggers errors when I try to import data with NULL fields. It can be fixed with a search and replace but I'd like to learn more about this problem. Any info?

View Replies !
LIKE And IS NOT NULL
Are the LIKE and IS NOT NULL options available in MySQL - these 2 options
are availble in Access and MS SQL.

LIKE is for searching using wildcards - e.g WHERE Name Like 'AD%'.

View Replies !
Getting The Null
I have two tables to compare
Code:
Schedule of Subject(table 1) previous subject taken(table 2)
Semister ID Subj ID | Semister ID Subj ID
1 1 | 1 1
1 2 | 1 2
1 3 | 1 3
1 4 | null null
1 5 | null null



My PK for this should be Semister ID.

My table 2 has only 3 records, so obviously if I compare
table2 from table1 (which has 6 records), table 2 should show the null value because it has no record for the following semister and subjects.

View Replies !
NULL/NOT NULL
I'm drawing a blank when it comes to using NULL/NOT NULL in my tables... can someone refresh my memory about this option in laemen terms. Also how or why does the field with this option have "NULL" entered in the field as the default value?

View Replies !
NULL Or Zero
`timestampLastFailedLogin` int(11),
If there is no value(field was never accessed or used) should I leave it with NULL value
or should I give it 0 as default value as follows?

`timestampLastFailedLogin` int(11) UNSIGNED NOT NULL DEFAULT '0'

View Replies !
WHERE A OR B OR C IS NOT NULL
I am trying to sort my recordset so that records will only display if certain columns contain information. I am unsure of the syntax on this. My first two columns will always be populated with data, but I only want to display the record if any one of the rest of the columns contain data. I know that .Code:

SELECT *
WHERE a OR b OR c IS NOT NULL

is not quite right.

View Replies !
Using NULL Vs 0
I have a DB i MySQL that uses many int(1) type fields. I store there some time value 0 or NULL.
My question is which solution is faster from DB point of view?
Should I store NULL for all those fields or is "0" better solution?
Which one takes less space and time to process?

View Replies !
NULL And NOT NULL
I understand the meaning of NULL, but I don't understand its usage. For example, a field declared to be NOT NULL, but has a NULL value. Or when a field is declared to be NULL, and yet values can still be placed into it. I don't understand the logic behind this.

View Replies !
IS NOT NULL
I tried below mentioned sql statement

mysql> SHOW COLUMNS FROM Country WHERE `Default` IS NOT NULL;


and suprinsgly it even list down those record as well where coloumn 'default' is NULL

Note : In the preceding statement, the column name (Default) must be given as a quoted identifier because it is a reserved word.


Any specific reason why it produced record having value as NULL, i tried somewhat similar to my own table , and it works fine for my other table.

View Replies !
WHERE Id NOT IN (NULL)
CREATE TABLE t (id INTEGER PRIMARY KEY);
INSERT INTO t SET id=1;
SELECT * FROM t WHERE id NOT IN (2); # one row
SELECT * FROM t WHERE id NOT IN (NULL); # empty set

This is a big surprise, since in my mind 1 is not in (NULL).

Here's another strange difference:

SELECT (1 IN (NULL)); # (NULL)
SELECT (1 IN (2)); # (0)

View Replies !
Null OR Value
how can I write a query that will return results that are either null or a specified value e.g.

e.g something like

SELECT * FROM Table 1 where ID = null OR 5

View Replies !
Null Vs Not Null
I create a field in a table as a "Not Null" would this prevent a new record to be created unless that field is properly filled?
I'm playing around with a test website and I tried leaving blank a "Not null" field but the record was created anyway with that field empty.
Maybe I'm not understanding the Null vs Notnull stuff correctly?
If so, how would one restrict the creation of new records unless a not null field contains valid (or data at all) data?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved