Home > database >  Novice programmers, the great god can help me see what's the problem with the MySQL SQL stateme
Novice programmers, the great god can help me see what's the problem with the MySQL SQL stateme

Time:09-28

The CREATE TABLE ` news ` (
` id ` int (11), NOT NULL AUTO_INCREMENT,
` title ` text,
` st ` varchar (100) the DEFAULT NULL,
` author ` varchar (100) the DEFAULT NULL,
` news_type_id ` int (11) the DEFAULT NULL,
` browser_count ` int (11) the DEFAULT ` 0 `,
` photo ` varchar (200) the DEFAULT NULL,
PRIMARY KEY (` id `),
The KEY ` news_type_id ` (` news_type_id `),
The CONSTRAINT ` news_ibfk_1 ` FOREIGN KEY (` news_type_id `) REFERENCES ` news_type ` (` id `)
);

CodePudding user response:

` browser_count ` int (11) the DEFAULT ` 0 `???????
You are defined as type int to a string for the default value? The single quotation marks,

CodePudding user response:

reference 1st floor weixin_39646155 response:
` browser_count ` int (11) the DEFAULT ` 0 `???????
You are defined as type int to a string for the default value? The single quotation marks,

Emmm, still won't do,,,

CodePudding user response:

refer to the second floor bestlanguagePHP response:
Quote: refer to 1st floor weixin_39646155 response:

` browser_count ` int (11) the DEFAULT ` 0 `???????
You are defined as type int to a string for the default value? The single quotation marks,

Emmm, still won't do,,,

An error message

CodePudding user response:

The CONSTRAINT ` news_ibfk_1 ` FOREIGN KEY (` news_type_id `) REFERENCES ` news_type ` (` id `)
Given the constraints, news_type_id default values cannot be empty

CodePudding user response:

reference weixin_39646155 reply: 3/f
Quote: refer to the second floor bestlanguagePHP response:

Quote: refer to 1st floor weixin_39646155 response:

` browser_count ` int (11) the DEFAULT ` 0 `???????
You are defined as type int to a string for the default value? The single quotation marks,

Emmm, still won't do,,,

An error message to see

[Err] 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 '? The CREATE TABLE ` news ` (
` id ` int (11), NOT NULL AUTO_INCREMENT,
` title ` Tex 'at line 1

CodePudding user response:

The
reference 4 floor qq_37496900 reply:
CONSTRAINT ` news_ibfk_1 ` FOREIGN KEY (` news_type_id `) REFERENCES ` news_type ` (` id `)
Given the constraints, news_type_id default value cannot be null

Defaults to 0

CodePudding user response:

` browser_count ` int (11) the DEFAULT ` 0 `,

CodePudding user response:

` browser_count ` int (11) the DEFAULT ` 0 `
This line ` ` 0 to 0

CodePudding user response:

CodePudding user response:

 create table news_type (
Id int AUTO_INCREMENT not null,
Val1 varchar (20) default ',
Primary key (id)
);

The CREATE TABLE ` news ` (
` id ` int (11), NOT NULL AUTO_INCREMENT,
` title ` text,
` st ` varchar (100) the DEFAULT NULL,
` author ` varchar (100) the DEFAULT NULL,
` news_type_id ` int (11) not null,
` browser_count ` int (11) the DEFAULT is 0,
` photo ` varchar (200) the DEFAULT NULL,
PRIMARY KEY (` id `),
The KEY ` news_type_id ` (` news_type_id `),
The CONSTRAINT ` news_ibfk_1 ` FOREIGN KEY (` news_type_id `) REFERENCES ` news_type ` (` id `)
);

CodePudding user response:

The
references to the tenth floor qq_37496900 response:
 create table news_type (
Id int AUTO_INCREMENT not null,
Val1 varchar (20) default ',
Primary key (id)
);

The CREATE TABLE ` news ` (
` id ` int (11), NOT NULL AUTO_INCREMENT,
` title ` text,
` st ` varchar (100) the DEFAULT NULL,
` author ` varchar (100) the DEFAULT NULL,
` news_type_id ` int (11) not null,
` browser_count ` int (11) the DEFAULT is 0,
` photo ` varchar (200) the DEFAULT NULL,
PRIMARY KEY (` id `),
The KEY ` news_type_id ` (` news_type_id `),
The CONSTRAINT ` news_ibfk_1 ` FOREIGN KEY (` news_type_id `) REFERENCES ` news_type ` (` id `)
);

Good, thank you brother

CodePudding user response:

refer to the eighth floor baozirui response:
` browser_count ` int (11) the DEFAULT ` 0 `
This line ` ` 0 to 0

Can the
  • Related