2013-05-08 2 views
-1
나는 테이블 직원을 만든

작동하지 않습니다와 나는 출력이 표시가 삽입 쿼리

내가이

를 삽입하지

client.query('INSERT INTO employees (id,firstName, lastName, fullName, managerId, managerName, title, department, cellPhone, officePhone, email, city, pic, twitterId, blog) VALUES (1,"amina", "yousuf", "aminayousuf",1,,"",,"ceo","df","4334","455","dfsfsdf","dsfsf","fdfdsf", "fsdf" ,"sdf")', function(err,data){ 
    if(err){ 
     console.log(" not inserted") ; 

    } 
    else{ 
     console.log("insert"); 
    } 
    client.end(); 

간단한 쿼리를 작성하고이 테이블에 데이터를 삽입 할 직원 테이블 생성

client.query('CREATE TABLE employees ' + 
'(id INT(11),' + 
' firstName VARCHAR(255), ' + 
' lastName VARCHAR(255), '+ 
' fullName VARCHAR(255),' + 
'managerId INT(11),'+ 
'managerName VARCHAR(255),'+ 
'title VARCHAR(255),'+ 
'department VARCHAR(255),'+ 
'cellPhone VARCHAR(255),' + 
'officePhone VARCHAR(255),' + 
'email VARCHAR(255),' + 
'city VARCHAR(255),'+ 
'pic BLOB ,' + 
'twitterId VARCHAR(255),' + 
'blog VARCHAR(255))' 
); 

쿼리를 작성하는 데 문제가 있습니까?

+2

그리고 '오류'는 무엇입니까? 다른 사람에게 물어보기 전에 반환 된 오류를 항상 확인하십시오. –

+0

검색어가 잘못되었습니다. 당신은'1 ,, ", ,, ,, 사용됩니다. 그건 옳지 않아. –

답변

1

쿼리 구문이 잘못되었으므로 values 섹션에 쉼표가 2 개 추가됩니다 (빈 문자열 값 주변). 대신 다음을 시도하십시오 :

INSERT INTO employees (
    id, firstName, lastName, fullName, managerId, managerName, title, 
    department, cellPhone, officePhone, email, city, pic, twitterId, blog 
) 
VALUES (
    1,"amina", "yousuf", "aminayousuf",1,"","ceo", 
    "df","4334","455","dfsfsdf","dsfsf","fdfdsf", "fsdf" ,"sdf" 
)