SQL Error: 1364 - Field 'buys' doesn't have a default value

2k Views Asked by At

I am getting this error in mybb SQL table:

SQL Error: 1364 - Field 'buys' doesn't have a default value Query: INSERT INTO mybb_bank_post ('pid','cost') VALUES ('1680','10000')

How can I resolve this?

1

There are 1 best solutions below

0
Gordon Linoff On

This suggests that buys is declared NOT NULL. So, you need to assign it a value when you insert into the table:

INSERT INTO mybb_bank_post (pid, cost, buys)
    VALUES (1680, 10000, 0);

Or, declare the table so buys is not NOT NULL -- that is NULL values are allowed. Or, provide a default value in the table definition.

Note: Do not use single quotes for column names or for numeric constants. Only use single quotes for strings and date constants.