user3800620
user3800620

Reputation: 3

SQL QUERY ERROR "DEFAULT NULL"

I am trying to write an sql query in PHP My admin ,but facing an error could any one help please!

QUERY

ALTER TABLE `transactions` ADD `giftAmount` FLOAT NOT NULL DEFAULT '0' AFTER `recievingCurrency` ,
ADD `giftCurrency` VARCHAR NULL DEFAULT NULL AFTER `giftAmount`

ERROR

#1064 - 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 'NULL DEFAULT NULL AFTER giftAmount' at line 2

HELP

Upvotes: 0

Views: 2351

Answers (2)

mvp
mvp

Reputation: 116177

Your syntax is not correct. Try:

ALTER TABLE `transactions`
  ADD `giftAmount`   FLOAT   NOT NULL DEFAULT '0'  AFTER `recievingCurrency` ,
  ADD `giftCurrency` VARCHAR                       AFTER `giftAmount`

You don't need to explicitly say DEFAULT NULL - it already is NULL by default.

Upvotes: 2

Sadikhasan
Sadikhasan

Reputation: 18600

You have to give size of varchar datatype like

ADD `giftCurrency` VARCHAR(100) DEFAULT NULL AFTER `giftAmount`

Upvotes: 1

Related Questions