Help with SQL Query..

Status
Not open for further replies.

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
I am trying to install pastebin and when I run this query I get this error



SCRIPTL

PHP:
CREATE TABLE `pastebin` (
      `pid` int(11) NOT NULL auto_increment,
      `poster` varchar(16) default NULL,
      `posted` datetime default NULL,
      `code` text,
      `parent_pid` int(11) default '0',
      `format` varchar(16) default NULL,
      `codefmt` mediumtext,
      `codecss` text,
      `domain` varchar(255) default '',
      `expires` DATETIME,
      `expiry_flag` ENUM('d','m', 'f') NOT NULL DEFAULT 'm',
      
      PRIMARY KEY  (`pid`),
      KEY `domain` (`domain`),
      KEY `parent_pid`,
      KEY `expires`
    );

create table recent
(
    domain varchar(255),
    pid int not null,
    seq_no int not null,
    
    primary key(domain,seq_no)
);


ERRO:
Error

SQL query:
CREATE TABLE `pastebin` ( `pid` int( 11 ) NOT NULL AUTO_INCREMENT ,
`poster` varchar( 16 ) default NULL ,
`posted` datetime default NULL ,
`code` text,
`parent_pid` int( 11 ) default '0',
`format` varchar( 16 ) default NULL ,
`codefmt` mediumtext,
`codecss` text,
`domain` varchar( 255 ) default '',
`expires` DATETIME,
`expiry_flag` ENUM( 'd', 'm', 'f' ) NOT NULL DEFAULT 'm',
PRIMARY KEY ( `pid` ) ,
KEY `domain` ( `domain` ) ,
KEY `parent_pid` ,
KEY `expires`
);


MySQL said:
#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 '
KEY `expires`
)' at line 16



Will pay 50 points.
 
Last edited:

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
You need to have brackets around the KEY parts.

Eg:
KEY (`parent_pid`),
KEY (`expires`)

Here is the fixed and working sql query.
Code:
CREATE TABLE `pastebin` (
      `pid` int(11) NOT NULL auto_increment,
      `poster` varchar(16) default NULL,
      `posted` datetime default NULL,
      `code` text,
      `parent_pid` int(11) default '0',
      `format` varchar(16) default NULL,
      `codefmt` mediumtext,
      `codecss` text,
      `domain` varchar(255) default '',
      `expires` DATETIME,
      `expiry_flag` ENUM('d','m', 'f') NOT NULL DEFAULT 'm',
      
      PRIMARY KEY  (`pid`),
      KEY `domain` (`domain`),
      KEY (`parent_pid`),
      KEY (`expires`)
    );

create table recent
(
    domain varchar(255),
    pid int not null,
    seq_no int not null,
    
    primary key(domain,seq_no)
);
 
Status
Not open for further replies.
Top