0

I am working on magento platform.I face a problem regarding values insertion to specific field: My query run perfect but one specific column not working for any query.I try my best but didn't find why .When i change the column type from int to varchar type it works.This is my table structure.

CREATE TABLE `followupemails_emaillogs` (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `schedule_time` datetime DEFAULT NULL,
  `sent_time` datetime DEFAULT NULL,
  `email_status` varchar(100) DEFAULT NULL,
  `client_name` varchar(250) DEFAULT NULL,
  `client_email` varchar(250) DEFAULT NULL,
  `followupemails_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1.

the "followupemails_id" column not working in insert and update query.This is one update query where record exist that id(29). UPDATE followupemails_emaillogs SET followupemails_id=5 WHERE id =29. This is insertion query INSERT INTO followupemails_emaillogs SET followupemails_id=4, schedule_time='2013-10-23 08:10:00', email_status='pending', client_name='ayaz ali'.this works fine on fiddle but not on my sqlyog ? what could be the issue.At last i find query that work perfect

.INSERT INTO followupemails_emaillogs (followupemails_id,schedule_time,email_status,client_name,client_email) VALUES (26,'2013-10-23 08:10:00','pending','ayaz ali','mamhmood@yahoo.com'); Can anyone tell me why set query not working but second query works perfect.so that i can accept his answer.Thanks for all your help

4

3 回答 3

2

Try like this

To Create,

CREATE TABLE followupemails_emaillogs (
  id int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  schedule_time datetime DEFAULT NULL,
  sent_time datetime DEFAULT NULL,
  email_status varchar(100) DEFAULT NULL,
  client_name varchar(250) DEFAULT NULL,
  client_email varchar(250) DEFAULT NULL,
  followupemails_i int(11) DEFAULT NULL,
  UNIQUE (id)
)

To Insert,

INSERT INTO followupemails_emaillogs (schedule_time,sent_time,email_status,client_name,client_email,followupemails_i) 
VALUES 
('2012-05-05','2012-05-06',"sent","sagar","sagar@xxxx.com",2)
于 2013-10-23T05:50:39.193 回答
0

don't need (11) in the sql query for int operator , This get for length of the nvarchar,varchar datatype column only not a int datatype,So change and write int instead of int(11) and int(8)

Try this query instead of your query

CREATE TABLE `followupemails_emaillogs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `schedule_time` datetime DEFAULT NULL,
  `sent_time` datetime DEFAULT NULL,
  `email_status` varchar(100) DEFAULT NULL,
  `client_name` varchar(250) DEFAULT NULL,
  `client_email` varchar(250) DEFAULT NULL,
  `followupemails_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1.
于 2013-10-23T04:35:55.487 回答
0

the whole query is ok

CREATE TABLE `followupemails_emaillogs` (
`id` int NOT NULL AUTO_INCREMENT,
  `schedule_time` datetime DEFAULT NULL,
  `sent_time` datetime DEFAULT NULL,
  `email_status` varchar(100) DEFAULT NULL,
  `client_name` varchar(250) DEFAULT NULL,
  `client_email` varchar(250) DEFAULT NULL,
  `followupemails_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1.

but at the last there is dot which is actually error so remove the dot and create the table

latin1.

so remove the dot sign and not null in id filed use this line by default fields are null so don't use default null

id int (8) AUTO_INCREMENT

CREATE TABLE `followupemails_emaillogs` (
`id` int (8) AUTO_INCREMENT,
  `schedule_time` datetime DEFAULT NULL,
  `sent_time` datetime DEFAULT NULL,
  `email_status` varchar(100),
  `client_name` varchar(250),
  `client_email` varchar(250),
  `followupemails_id` int,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
于 2013-10-23T04:54:49.093 回答