Mysql 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 site About Us Learn more about Stack Overflow mysql error code 1048. column cannot be null the company Business Learn more about hiring developers or posting ads with us Stack error code 1048 in mysql Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of
Error Number 1048 Column Cannot Be Null In Codeigniter
6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR 1048 (23000) Column cannot be NULL, however I am inserting valid data up vote 5 down vote
Column Cannot Be Null Mysql
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 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 sql error 1048 sqlstate 23000 hibernate 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 *************************** Trigger: insertuser Event: INSERT Table: z Statement: begin call triggerproc(sysdate(),user(),(select data from z where a = last_insert_id())); end Timing: AFTER Created: NULL sql_mode: NO_ENGINE_SUBSTITUTION Definer: root@localhost character_set_client: utf8 collation_connection: utf8_general_ci Database Collation: latin1_swedish_ci 1 row in set (0.00 sec) And the Procedure: mysql> show create procedure triggerproc\G *************************** 1. row
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the
Error Number 1048 Column Name Cannot Be Null In Codeigniter
workings and policies of this site About Us Learn more about Stack error number 1048 in codeigniter Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs mysql column cannot be null default value Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join http://stackoverflow.com/questions/25154105/error-1048-23000-column-cannot-be-null-however-i-am-inserting-valid-data them; it only takes a minute: Sign up MySQL Error Code: 1048: Column cannot be null up 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, http://stackoverflow.com/questions/37994365/mysql-error-code-1048-column-cannot-be-null 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) 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 w
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 Learn more http://stackoverflow.com/questions/34422253/error-1048-column-cannot-be-null-in-mysql-lookup-table-something-missing 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 Community Stack https://www.sitepoint.com/community/t/column-id-cannot-be-null/4541 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 1048. column cannot be null in Mysql lookup table-something missing? cannot be up vote 0 down vote favorite I want to add data to a lookup table locations_borrowers (id_location_borrower (PK), id_borrower (FK), id_location (FK)) from 3 different tables: borrowers (id_borrower (PK), forename, surname) locations (id_location (PK), street, town) all_proto (borrower_forename, borrower_surname, street, town, occupation, telephone) I wrote the following: INSERT INTO schema.locations_borrowers (id_borrower, id_location) SELECT borrowers.id_borrower, locations.id_location FROM borrowers JOIN schema.all_proto ON borrowers.forename = all_proto.borrower_forename AND borrowers.surname = all_proto.borrower_surname LEFT JOIN cannot be null locations ON locations.street = all_proto.street AND locations.town = all_proto.town; I got an 1048 error, what is wrong? mysql lookup-tables share|improve this question edited Dec 28 '15 at 17:19 Mark Amery 24.1k12119150 asked Dec 22 '15 at 18:29 iregood 12 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote MySQL :: Error: 1048 Column cannot be null for Insert Since you are using LEFT JOIN the column locations.id_location may be null. This should always be INNER JOIN since you are expecting both values to be NOT NULL. (If not the table is not making any sense, no?) share|improve this answer answered Dec 22 '15 at 18:36 Sam Segers 1,32121321 I just put the INNER JOIN but a 1054 error come up: Unknown column 'Id_location' in 'field list' –iregood Dec 22 '15 at 18:40 Check for typos. Either in your table or in your query. Is 'id_location' consistently the same everywhere? –Sam Segers Dec 22 '15 at 18:45 yes I had a little typo. However it now runs the command without errors but nothing happened: 0 row(s) affected Records: 0 Duplicates: 0 Warnings: 0 –iregood Dec 22 '15 at 18:53 Add some da
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