2009-04-15 3 views
3

"텍스트"유형의 열에 쓸 때 내 쿼리가 엉망입니다. MySQL 텍스트 열에 문자열을 삽입 할 수 없습니다.

Describe messages; 

Field   Type   Null Key Default Extra 
id   int(11)  NO PRI NULL  auto_increment 
title   varchar(255) YES  NULL 
body   text   YES  NULL 
to   text   YES  NULL 
content_type varchar(255) YES  NULL 
is_sms  tinyint(1) YES  NULL 
user_id  int(11)  YES  NULL 
created_at datetime  YES  NULL 
updated_at datetime  YES  NULL 

그럼 내가 삽입을 시도하십시오 : 이것은 일반적으로 MySQL의 구문 오류가 발생 어떤 이유로

INSERT INTO messages (id,title,body,to) VALUES ('1','Test Message','This is a test message. This is a test message. This is a test message. This is a test message.', 'an email'); 

다음은 예입니다. "받는 사람"열을 제거하고 해당 값을 쿼리에서 제거하면 쿼리가 올바르게 작동합니다.

아이디어가 있으십니까?

답변

3
INSERT 
INTO  messages (id,title,body,`to`) 
VALUES ('1','Test Message','This is a test message. This is a test message. This is a test message. This is a test message.', 'an email'); 
4

대신

INSERT INTO messages (`id`,`title`,`body`,`to`) 
    VALUES ('1','Test Message','This is a test message. 
    This is a test message. This is a test message. This is a test message.', 
    'an email'); 
1

당신은 "을"backtics 너무처럼 둘러싸고 경우 내가 믿는이 시도 :

INSERT INTO messages (id,title,body,`to`) VALUES ('1','Test Message','This is a test message. This is a test message. This is a test message. This is a test message.', 'an email'); 

그것이 작동이 - 나를 위해 한을 어쨌든.

0

MySQL에 변수가 정의되어 있지 않습니다. 예 : 'to', 'not', 'join'을 사용하지 마십시오 ...

INSERT INTO 메시지 (ID, 제목, 본문, 테스트) VALUES ('1', 'Test Message', '이것은'입니다. 테스트 메시지입니다. 이것은 테스트 메시지입니다. 테스트 메시지입니다. 테스트 메시지입니다. ', '전자 메일 ');

관련 문제