Mysql Sql Error 1048
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Mysql Error 1048 Column Cannot Be Null
site About Us Learn more about Stack Overflow the company Business Learn error number 1048 column cannot be null in codeigniter more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question column cannot be null mysql x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR
Error Code 1048 Mysql
1048 (23000) Column cannot be NULL, however I am inserting valid data up vote 5 down vote favorite There are tons of these posts on Stack Overflow, however from the 20 or so that I looked at they were either coding errors faced when interfacing with MySQL (which I am not trying to do) or simply wanted null values but had their table defined
Sql Error 1048 Sqlstate 23000 Hibernate
incorrectly. I am seeing an error in MySQL 5.6.19 where I have a column that is not allowed to have a null value. This is fine as it shouldn't have a null value. Here is the table desc below. mysql> describe z; +-------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+----------------+ | a | int(11) | NO | PRI | NULL | auto_increment | | data | char(30) | NO | | NULL | | | t | datetime | YES | | NULL | | +-------+----------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) My problem is that I am inserting valid data.... mysql> insert into z (data, t) values('helloworld', sysdate()); ERROR 1048 (23000): Column 'data' cannot be null There is one other piece of information that might be of some concern... or may not be. I have a trigger and procedure that execute upon the implementation of inserts into this column. However I don't see that it should be a problem due to the trigger being activated after the insert statement completes. Here is the trigger: mysql> show triggers\G *************************** 1. row *
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this error number 1048 column name cannot be null in codeigniter site About Us Learn more about Stack Overflow the company Business Learn more
Error Number 1048 In Codeigniter
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x mysql column cannot be null default value Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mySQL trigger? http://stackoverflow.com/questions/25154105/error-1048-23000-column-cannot-be-null-however-i-am-inserting-valid-data causing Error Code: 1048 Column cannot be null up vote 0 down vote favorite I have seen similar questions asked but never seen an answer that works for me. I have the following table and trigger definitions... DROP TRIGGER IF EXISTS c_consumption.newRateHistory; DROP TABLE IF EXISTS c_consumption.myrate; DROP TABLE IF EXISTS c_consumption.myratehistory; USE c_consumption; CREATE TABLE `myrate` ( `consumerId` varchar(255) DEFAULT NULL, `durationType` varchar(50) NOT http://stackoverflow.com/questions/25413705/mysql-trigger-causing-error-code-1048-column-cannot-be-null NULL DEFAULT 'DAY', `id` bigint(20) NOT NULL AUTO_INCREMENT, `itemId` varchar(50) NOT NULL, `quantity` double NOT NULL DEFAULT 1.0, `quantityType` varchar(100) NOT NULL DEFAULT 'GALLON', `timePeriod` double NOT NULL DEFAULT 1.0, PRIMARY KEY (`id`), UNIQUE INDEX `UNIQUE_RATE` (`itemId` ASC, `consumerId` ASC) ) ENGINE=InnoDB AUTO_INCREMENT=314 DEFAULT CHARSET=utf8; CREATE TABLE `myratehistory` ( `consumerId` varchar(255) DEFAULT NULL, `durationType` varchar(50) DEFAULT NULL, `itemId` varchar(50) NOT NULL, `quantity` double DEFAULT NULL, `quantityType` varchar(100) DEFAULT NULL, `status` varchar(20) NOT NULL DEFAULT 'CREATED', `timePeriod` double DEFAULT NULL, `timestamp` DATETIME NULL, PRIMARY KEY (`itemId`, `consumerId`, `timestamp`) ) ENGINE=InnoDB AUTO_INCREMENT=314 DEFAULT CHARSET=utf8; CREATE TRIGGER `newRateToHistory` AFTER INSERT ON myrate FOR EACH ROW INSERT INTO myratehistory ( consumerId, durationType, itemId, quantity, quantityType, status, timePeriod, timestamp ) VALUES( new.consumerId, new.durationType, new.itemId, new.quantity, new.quantityType, 'CREATED', new.timePeriod, now()); Note that consumerId CAN be null. Next I run this SQL statement: INSERT INTO c_consumption.myrate ( consumerId, durationType, itemId, quantity, quantityType, timePeriod) VALUES( null, 'DAY', 'MyItem', 1.0, 'GALLON', 1.0); I get the following message: Error Code: 1048 Column 'consumerId' cannot be null Obviously I am doing something wrong but I do not know what it is. Any help would be greatly appreciated. Thanks! mysql sql triggers
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/37994365/mysql-error-code-1048-column-cannot-be-null Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow https://www.sitepoint.com/community/t/column-id-cannot-be-null/4541 Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Error Code: 1048: Column cannot be null up cannot be vote 0 down vote favorite I have a query: SELECT COUNT(*) FROM (SELECT vendors_id, merchants_id, SUM(amount) AS amount, SUM(commission_amount) AS commission_amount FROM (SELECT vendors_id, merchants_id, amount, commission_amount FROM (SELECT vendors.id AS vendors_id, merchants_id, SUM(transactions_cash.amount) AS amount, SUM( transactions_cash.commission_amount ) AS commission_amount FROM ibaserver.transactions_cash, ibaserver.vendors, ibaserver.merchants WHERE transactions_cash.vendors_id = vendors.id AND TIME > 1466680920208 AND TIME <= 1466681880067 AND merchants_id = merchants.id GROUP BY transactions_cash.merchants_id ORDER BY transactions_cash.merchants_id) cannot be null a UNION ALL SELECT vendors_id, merchants_id, amount, commission_amount FROM (SELECT vendors.id AS vendors_id, merchants_id, SUM( transactions_cash_archive.amount ) AS amount, SUM( transactions_cash_archive.commission_amount ) AS commission_amount FROM ibaserver.transactions_cash_archive, ibaserver.vendors, ibaserver.merchants WHERE transactions_cash_archive.vendors_id = vendors.id AND TIME > 1466680920208 AND TIME <= 1466681880067 AND merchants_id = merchants.id GROUP BY transactions_cash_archive.merchants_id ORDER BY transactions_cash_archive.merchants_id) b) s) q And when the inner query SELECT vendors_id, name, amount FROM .... returns the data, the result is returned successfully. If the inner query returns only NULL: the entire query returns an error: Error Code: 1048 Column 'vendors_id' cannot be null How to return 0 in the case when the inner query returns all of a NULL? mysql share|improve this question edited Jun 23 at 14:39 asked Jun 23 at 14:20 Ksenia 251214 1 why bother doing the sum() in the subquery, when all you want is a count() in the external query? that's a lot of extra work for the DB that's simply thrown away/ignored. why can't you have just select count(*) from sometable? –Marc B Jun 23 at 14:22 @MarcB, I've edited the post. I think it is not essential. –Ksenia Jun 23 at 14:26 same thing holds. you're not doing anyth
INSERT INTO usertbl (id,OrgId,InstId,userType,timein) VALUES(NULL, '42824149', '12345678', '3','1229648361'); MySQL Error : Column 'id' cannot be null Error Number : 1048 IBazz 2008-12-19 01:22:37 UTC #2 Sahajin said: Invalid SQL: INSERT INTO usertbl (id,OrgId,InstId,userType,timein) VALUES(NULL, '42824149', '12345678', '3','1229648361');MySQL Error : Column 'id' cannot be nullError Number : 1048 I seem to recall that because auto_increment is built by MySQL, that you don't put an entry for that column. That means, it should be like this INSERT INTO usertbl (OrgId,InstId,userType,timein) VALUES( '42824149', '12345678', '3','1229648361'); hth bazz r937 2008-12-19 01:23:38 UTC #3 Sahajin, please do a SHOW CREATE TABLE for your table bazz, you're right, it should work without mentioning the auto_increment, but it should also work the way it was and by the way, please don't make strings out of numbers needlessly Sahajin 2008-12-19 01:29:30 UTC #4 Thanks, r937, I don't know what they will be, in this example they are numbers, but the next one could be letters as well. I will get the table as soon as the admin gets online Sahajin 2008-12-19 01:31:04 UTC #5 I do have another table that it happens to, mysql> explain sessions; +-----------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+------------------+------+-----+---------+----------------+ | session_id | int(11) unsigned | NO | PRI | NULL | auto_increment | | session | varchar(255) | NO | MUL | NULL | | | session_expires | int(11) unsigned | NO | | 0 | | | session_data | text | YES | | NULL | | +-----------------+------------------+------+-----+---------+----------------+ The query is this $query = "INSERT INTO sessions (session_id,session,session_expires,session_data) VALUES(NULL,'$sessID', $newExp, '$sessData')"; fails on session_id as well. "Cannot be NULL" r937 2008-12-19 01:36:36 UTC #6 well, of course it works on that table, but that's not the table you're having the tr