MAO February 2016

how to update columns with empty value

Im using mysql, when I want to update a column with this query

UPDATE books 
   SET ISBN = $ISBN
     , Title = '$BookTitle'
     , PublicationDate = '$PublicationDate'
     , Publisher = '$Publisher'
     , Edition = $Edition
     , Volume = $Volume
     , books.Author_AuthorId = $AuthorId 
 WHERE ISBN = $GETISBN;

with php it works well while all the input are filled in HTML FORM but if one input is empty already or I clear the previous data in HTML Form and Submit the Form it issues this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Volume=1, books.Author_AuthorId=3 WHERE ISBN=5456165156' at line 2

What Should I do?

Answers


MAO February 2016

Here is the query which I have echoed

UPDATE `books` SET `ISBN`=5456165156,`Title`='500 Notice About Java',`PublicationDate`='1390-05-25', `Publisher`='Qods Publication',`Edition`=,`Volume`=1, `books`.`Author_AuthorId`=3 WHERE `ISBN`=5456165156

As long as The $Edition is empty Then The Query Changes like this

`Edition`=

Thats why Mysql can not Understand what value should be set to Edition

Post Status

Asked in February 2016
Viewed 3,286 times
Voted 14
Answered 1 times

Search




Leave an answer