#1064 - You have an error in your SQL syntax; - mysql

CREATE TABLE `mealorder`.`order_item`
( `order_id` INT(20) NOT NULL AUTO_INCREMENT ,
`user_id` INT(20) NOT NULL ,
`item_type` VARCHAR(50) NOT NULL ,
`item_price` DOUBLE(20) NOT NULL ,
`item_quantity` INT(20) NULL ,
`date_time` DATETIME(5) NULL ,
`total_price` DOUBLE(20) NULL ,
PRIMARY KEY (`order_id`(20))) ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `order_item` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`item_type` varchar(50) NOT NULL,
`item_price` double NOT NULL,
`item_quantity` int(11) NOT NULL,
`date_time` datetime NOT NULL,
`total_price` double NOT NULL,
PRIMARY KEY (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
AUTO_INCREMENT=1 ;

Related

error in SQL syntax near primary key

CREATE TABLE `bank`.`Customer_registrationTable`
( `Account_no` INT NOT NULL ,
`Name` VARCHAR(100) NOT NULL ,
`Address` INT(100) NOT NULL ,
`Account_type` VARCHAR(100) NOT NULL ,
`Gender` VARCHAR(50) NOT NULL ,
`DOB` VARCHAR(100) NOT NULL ,
`Password` VARCHAR(100) NOT NULL ,
`Date` VARCHAR(100) NOT NULL ,
`Age` INT(10) NOT NULL ,
`Previous_Balance` DOUBLE(20) NOT NULL,
PRIMARY KEY (`Account_no`(30))) ENGINE = InnoDB;
after writing this I got problem that said,
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') NOT NULL, PRIMARY KEY (`Account_no`(30))) WHERE ENGINE = InnoDB' at line 1
CREATE TABLE `bank`.`Customer_registrationTable`
( `Account_no` INT NOT NULL ,
`Name` VARCHAR(100) NOT NULL ,
`Address` INT(100) NOT NULL ,
`Account_type` VARCHAR(100) NOT NULL ,
`Gender` VARCHAR(50) NOT NULL ,
`DOB` VARCHAR(100) NOT NULL ,
`Password` VARCHAR(100) NOT NULL ,
`Date` VARCHAR(100) NOT NULL ,
`Age` INT(10) NOT NULL ,
`Previous_Balance` DOUBLE NOT NULL,
PRIMARY KEY (`Account_no`)) ENGINE = InnoDB;
PRIMARY KEY (Account_no) should not have (20)
Previous_Balance DOUBLE NOT NULL should not have (20), it should like DOUBLE(20, 2)
CREATE TABLE IF NOT EXISTS `customer_registrationtable` (
`Account_no` int(11) NOT NULL,
`Name` varchar(100) NOT NULL,
`Address` int(100) NOT NULL,
`Account_type` varchar(100) NOT NULL,
`Gender` varchar(50) NOT NULL,
`DOB` datetime NOT NULL,
`Password` varchar(100) NOT NULL,
`Date` datetime NOT NULL,
`Age` int(10) NOT NULL,
`Previous_Balance` double(20,2) NOT NULL,
PRIMARY KEY (`Account_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

FlashChat installation hiccup! SQL syntax error?

I've done away with the (14) and (11) but when trying to install tufat's Flashchat, I keep getting this error:
Could not create DB table 'smf_fc_bans'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 '(14) NOT NULL, userid int(11)
default NULL, banneduserid int(11) default NULL, r' at line 1
Granted I'm still such a novice. If someone could help me I would be so very very grateful.
Table structure for table bans:
CREATE TABLE `bans` (
`id` int NOT NULL auto_increment,
`created` timestamp NOT NULL,
`userid` int default NULL,
`banneduserid` int default NULL,
`roomid` int default NULL,
`ip` varchar default NULL,
KEY `id` (`id`),
KEY `userid` (`userid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
Table structure for table connections:
CREATE TABLE `connections` (
`id` varchar(32) NOT NULL default '',
`updated` timestamp NOT NULL,
`created` timestamp NOT NULL,
`userid` int default NULL,
`roomid` int default NULL,
`state` tinyint(4) NOT NULL default '1',
`color` int default NULL,
`start` int default NULL,
`lang` char(2) default NULL,
`ip` varchar(16) default NULL,
`tzoffset` int default '0',
`chatid` int NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `userid` (`userid`),
KEY `roomid` (`roomid`),
KEY `updated` (`updated`)
) ENGINE=MyISAM;
Table structure for table ignors:
CREATE TABLE `ignors` (
`created` timestamp NOT NULL,
`userid` int default NULL,
`ignoreduserid` int default NULL,
KEY `userid` (`userid`),
KEY `ignoreduserid` (`ignoreduserid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
Table structure for table messages:
CREATE TABLE `messages` (
`id` int(11) NOT NULL auto_increment,
`created` timestamp NOT NULL,
`toconnid` varchar(32) default NULL,
`touserid` int(11) default NULL,
`toroomid` int(11) default NULL,
`command` varchar(255) NOT NULL default '',
`userid` int default NULL,
`roomid` int(11) default NULL,
`txt` text,
PRIMARY KEY (`id`),
KEY `touserid` (`touserid`),
KEY `toroomid` (`toroomid`),
KEY `toconnid` (`toconnid`),
KEY `created` (`created`)
) ENGINE=MyISAM AUTO_INCREMENT=14 ;
Table structure for table rooms:
CREATE TABLE `rooms` (
`id` int NOT NULL auto_increment,
`updated` timestamp NOT NULL,
`created` timestamp NOT NULL,
`name` varchar(64) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`ispublic` char(1) default NULL,
`ispermanent` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `ispublic` (`ispublic`),
KEY `ispermanent` (`ispermanent`),
KEY `updated` (`updated`)
) WNGINW=MyISAM AUTO_INCREMENT=5 ;
Table structure for table users:
CREATE TABLE `users` (
`id` int NOT NULL auto_increment,
`login` varchar(32) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`roles` int NOT NULL default '0',
`profile` text,
PRIMARY KEY (`id`),
KEY `login` (`login`)
) ENGINE=MyISAM AUTO_INCREMENT=2 ;`
The varchar datatype requires a parameter like varchar(50)
CREATE TABLE `bans` (
`id` int NOT NULL auto_increment,
`created` timestamp NOT NULL,
`userid` int default NULL,
`banneduserid` int default NULL,
`roomid` int default NULL,
`ip` varchar( requires a number ) default NULL, <-- HERE
KEY `id` (`id`),
KEY `userid` (`userid`),
KEY `created` (`created`)
) ENGINE=MyISAM;
You also have an error in
CREATE TABLE `rooms` (
`id` int NOT NULL auto_increment,
`updated` timestamp NOT NULL,
`created` timestamp NOT NULL,
`name` varchar(64) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`ispublic` char(1) default NULL,
`ispermanent` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `ispublic` (`ispublic`),
KEY `ispermanent` (`ispermanent`),
KEY `updated` (`updated`)
) WNGINW=MyISAM AUTO_INCREMENT=5 ;
WNGINW=MyISAM AUTO_INCREMENT=5 ;
Should be
ENGINE=MyISAM AUTO_INCREMENT=5 ;

osticket how to get ticket id by the form entry value?

In osticket we have a number of custom form fields setup and I need help querying them. The data that I want to query is stored in form_entry.value.
SELECT * FROM `form_entry_values` fev, `form_entry` fe WHERE fev.value = '{$ibn}' AND fe.id = fev.entry_id
This is returning the correct data but how can I find the ticket ID if i know the form_id? I can't seem to find any joining tables.
This is the full db: https://github.com/osTicket/osTicket-1.8/blob/b1c845bf0591b1f5da593a55e462b07e5a4ee5de/setup/inc/streams/core/install-mysql.sql
DROP TABLE IF EXISTS `form`;
CREATE TABLE `form` (
`id` int(11) unsigned NOT NULL auto_increment,
`type` varchar(8) NOT NULL DEFAULT 'G',
`deletable` tinyint(1) NOT NULL DEFAULT 1,
`title` varchar(255) NOT NULL,
`instructions` varchar(512),
`notes` text,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `form_field`;
CREATE TABLE `form_field` (
`id` int(11) unsigned NOT NULL auto_increment,
`form_id` int(11) unsigned NOT NULL,
`type` varchar(255) NOT NULL DEFAULT 'text',
`label` varchar(255) NOT NULL,
`required` tinyint(1) NOT NULL DEFAULT 0,
`private` tinyint(1) NOT NULL DEFAULT 0,
`edit_mask` tinyint(1) NOT NULL DEFAULT 0,
`name` varchar(64) NOT NULL,
`configuration` text,
`sort` int(11) unsigned NOT NULL,
`hint` varchar(512),
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `form_entry`;
CREATE TABLE `form_entry` (
`id` int(11) unsigned NOT NULL auto_increment,
`form_id` int(11) unsigned NOT NULL,
`object_id` int(11) unsigned,
`object_type` char(1) NOT NULL DEFAULT 'T',
`sort` int(11) unsigned NOT NULL DEFAULT 1,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `entry_lookup` (`object_type`, `object_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `form_entry_values`;
CREATE TABLE `form_entry_values` (
-- references form_entry.id
`entry_id` int(11) unsigned NOT NULL,
`field_id` int(11) unsigned NOT NULL,
`value` text,
`value_id` int(11),
PRIMARY KEY (`entry_id`, `field_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `list`;
CREATE TABLE `list` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`name_plural` varchar(255),
`sort_mode` enum('Alpha', '-Alpha', 'SortCol') NOT NULL DEFAULT 'Alpha',
`masks` int(11) unsigned NOT NULL DEFAULT 0,
`type` VARCHAR( 16 ) NULL DEFAULT NULL,
`notes` text,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `type` (`type`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `list_items`;
CREATE TABLE `list_items` (
`id` int(11) unsigned NOT NULL auto_increment,
`list_id` int(11),
`status` int(11) unsigned NOT NULL DEFAULT 1,
`value` varchar(255) NOT NULL,
-- extra value such as abbreviation
`extra` varchar(255),
`sort` int(11) NOT NULL DEFAULT 1,
`properties` text,
PRIMARY KEY (`id`),
KEY `list_item_lookup` (`list_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket`;
CREATE TABLE `ticket` (
`ticket_id` int(11) unsigned NOT NULL auto_increment,
`number` varchar(20),
`user_id` int(11) unsigned NOT NULL default '0',
`user_email_id` int(11) unsigned NOT NULL default '0',
`status_id` int(10) unsigned NOT NULL default '0',
`dept_id` int(10) unsigned NOT NULL default '0',
`sla_id` int(10) unsigned NOT NULL default '0',
`topic_id` int(10) unsigned NOT NULL default '0',
`staff_id` int(10) unsigned NOT NULL default '0',
`team_id` int(10) unsigned NOT NULL default '0',
`email_id` int(11) unsigned NOT NULL default '0',
`flags` int(10) unsigned NOT NULL default '0',
`ip_address` varchar(64) NOT NULL default '',
`source` enum('Web','Email','Phone','API','Other') NOT NULL default 'Other',
`isoverdue` tinyint(1) unsigned NOT NULL default '0',
`isanswered` tinyint(1) unsigned NOT NULL default '0',
`duedate` datetime default NULL,
`reopened` datetime default NULL,
`closed` datetime default NULL,
`lastmessage` datetime default NULL,
`lastresponse` datetime default NULL,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`ticket_id`),
KEY `user_id` (`user_id`),
KEY `dept_id` (`dept_id`),
KEY `staff_id` (`staff_id`),
KEY `team_id` (`team_id`),
KEY `status_id` (`status_id`),
KEY `created` (`created`),
KEY `closed` (`closed`),
KEY `duedate` (`duedate`),
KEY `topic_id` (`topic_id`),
KEY `sla_id` (`sla_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_attachment`;
CREATE TABLE `ticket_attachment` (
`attach_id` int(11) unsigned NOT NULL auto_increment,
`ticket_id` int(11) unsigned NOT NULL default '0',
`file_id` int(10) unsigned NOT NULL default '0',
`ref_id` int(11) unsigned NOT NULL default '0',
`inline` tinyint(1) NOT NULL default '0',
`created` datetime NOT NULL,
PRIMARY KEY (`attach_id`),
KEY `ticket_id` (`ticket_id`),
KEY `ref_id` (`ref_id`),
KEY `file_id` (`file_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_lock`;
CREATE TABLE `ticket_lock` (
`lock_id` int(11) unsigned NOT NULL auto_increment,
`ticket_id` int(11) unsigned NOT NULL default '0',
`staff_id` int(10) unsigned NOT NULL default '0',
`expire` datetime default NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`lock_id`),
UNIQUE KEY `ticket_id` (`ticket_id`),
KEY `staff_id` (`staff_id`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_email_info`;
CREATE TABLE `ticket_email_info` (
`id` int(11) unsigned NOT NULL auto_increment,
`thread_id` int(11) unsigned NOT NULL,
`email_mid` varchar(255) NOT NULL,
`headers` text,
PRIMARY KEY (`id`),
KEY `email_mid` (`email_mid`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_event`;
CREATE TABLE `ticket_event` (
`ticket_id` int(11) unsigned NOT NULL default '0',
`staff_id` int(11) unsigned NOT NULL,
`team_id` int(11) unsigned NOT NULL,
`dept_id` int(11) unsigned NOT NULL,
`topic_id` int(11) unsigned NOT NULL,
`state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL,
`staff` varchar(255) NOT NULL default 'SYSTEM',
`annulled` tinyint(1) unsigned NOT NULL default '0',
`timestamp` datetime NOT NULL,
KEY `ticket_state` (`ticket_id`, `state`, `timestamp`),
KEY `ticket_stats` (`timestamp`, `state`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_status`;
CREATE TABLE IF NOT EXISTS `ticket_status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) NOT NULL DEFAULT '',
`state` varchar(16) DEFAULT NULL,
`mode` int(11) unsigned NOT NULL DEFAULT '0',
`flags` int(11) unsigned NOT NULL DEFAULT '0',
`sort` int(11) unsigned NOT NULL DEFAULT '0',
`properties` text NOT NULL,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `state` (`state`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_priority`;
CREATE TABLE `ticket_priority` (
`priority_id` tinyint(4) NOT NULL auto_increment,
`priority` varchar(60) NOT NULL default '',
`priority_desc` varchar(30) NOT NULL default '',
`priority_color` varchar(7) NOT NULL default '',
`priority_urgency` tinyint(1) unsigned NOT NULL default '0',
`ispublic` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`priority_id`),
UNIQUE KEY `priority` (`priority`),
KEY `priority_urgency` (`priority_urgency`),
KEY `ispublic` (`ispublic`)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ticket_thread`;
CREATE TABLE `ticket_thread` (
`id` int(11) unsigned NOT NULL auto_increment,
`pid` int(11) unsigned NOT NULL default '0',
`ticket_id` int(11) unsigned NOT NULL default '0',
`staff_id` int(11) unsigned NOT NULL default '0',
`user_id` int(11) unsigned not null default 0,
`thread_type` enum('M','R','N') NOT NULL,
`poster` varchar(128) NOT NULL default '',
`source` varchar(32) NOT NULL default '',
`title` varchar(255),
`body` mediumtext NOT NULL,
`format` varchar(16) NOT NULL default 'html',
`ip_address` varchar(64) NOT NULL default '',
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `ticket_id` (`ticket_id`),
KEY `staff_id` (`staff_id`),
KEY `pid` (`pid`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `ticket_collaborator` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`isactive` tinyint(1) NOT NULL DEFAULT '1',
`ticket_id` int(11) unsigned NOT NULL DEFAULT '0',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
-- M => (message) clients, N => (note) 3rd-Party, R => (reply) external authority
`role` char(1) NOT NULL DEFAULT 'M',
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `collab` (`ticket_id`,`user_id`)
) DEFAULT CHARSET=utf8;
In the values table, there is a field object_id this is the ticket ID.
SELECT t.* FROM form_entry_values fev
LEFT JOIN form_entry fe ON(fev.entry_id = fe.id)
LEFT JOIN ticket t ON(fe.object_id = t.ticket_id)
WHERE fev.value = '123'
in the Osticket 1.15 version, the object_id in the form_entry has a relation to the user_id.
SELECT t.* FROM form_entry_values fev
LEFT JOIN form_entry fe ON fev.entry_id = fe.id
LEFT JOIN ticket t ON fe.object_id = t.user_id

SQL {setCharset} AUTO_INCREMENT=1' at line 1

DROP TABLE IF EXISTS `{DB_TABLE_PREFIX}broadcast`;
#[QUERY]
CREATE TABLE `{DB_TABLE_PREFIX}broadcast` (
`bid` mediumint(8) NOT NULL auto_increment,
`sortid` mediumint(8) NOT NULL default '0',
`content` varchar(255) NOT NULL default '',
`gourl` varchar(255) NOT NULL default '#',
PRIMARY KEY (`bid`)
) TYPE=MyISAM {setCharset} AUTO_INCREMENT=1 ;
#[QUERY]
DROP TABLE IF EXISTS `{DB_TABLE_PREFIX}items`;
#[QUERY]
CREATE TABLE `{DB_TABLE_PREFIX}items` (
`itemid` mediumint(8) unsigned NOT NULL auto_increment,
`uid` mediumint(8) unsigned NOT NULL default '0',
`account` varchar(15) NOT NULL default '',
`content` varchar(255) NOT NULL default '',
`dateline` int(10) unsigned NOT NULL default '0',
`digg` mediumint(8) unsigned NOT NULL default '0',
`reply` mediumint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`itemid`),
KEY `uid` (`uid`)
) TYPE=MyISAM {setCharset} AUTO_INCREMENT=1 ;
#[QUERY]
DROP TABLE IF EXISTS `{DB_TABLE_PREFIX}reply`;
#[QUERY]
CREATE TABLE `{DB_TABLE_PREFIX}reply` (
`rid` mediumint(8) NOT NULL auto_increment,
`replyto` mediumint(8) unsigned NOT NULL default '0',
`uid` mediumint(8) NOT NULL default '0',
`account` varchar(15) NOT NULL default '',
`content` varchar(255) NOT NULL default '',
`dateline` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`rid`),
KEY `uid` (`uid`),
KEY `replyto` (`replyto`)
) TYPE=MyISAM {setCharset} AUTO_INCREMENT=1 ;
#[QUERY]
DROP TABLE IF EXISTS `{DB_TABLE_PREFIX}setting`;
#[QUERY]
CREATE TABLE `{DB_TABLE_PREFIX}setting` (
`setname` varchar(255) NOT NULL default '',
`data` text NOT NULL,
PRIMARY KEY (`setname`)
) TYPE=MyISAM {setCharset} ;
I try to import this to mysql database and receive 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 '{setCharset} AUTO_INCREMENT=1' at line 1
Did I did miss something? Please help me out!
Try this:
CREATE TABLE `broadcast` (
`bid` mediumint(8) NOT NULL auto_increment,
`sortid` mediumint(8) NOT NULL default '0',
`content` varchar(255) NOT NULL default '',
`gourl` varchar(255) NOT NULL default '#',
PRIMARY KEY (`bid`)
) TYPE=MyISAM AUTO_INCREMENT=50 ;
The curly brackets were just for explanation as you refereed the syntax from some other source.
Replace
TYPE=MyISAM
by
ENGINE=MYISAM
Try this, I have used table prefix as "t_"
DROP TABLE IF EXISTS `t_broadcast`;
CREATE TABLE `t_broadcast` (
`bid` MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
`sortid` MEDIUMINT(8) NOT NULL DEFAULT '0',
`content` VARCHAR(255) NOT NULL DEFAULT '',
`gourl` VARCHAR(255) NOT NULL DEFAULT '#',
PRIMARY KEY (`bid`)
) ENGINE=MYISAM;
DROP TABLE IF EXISTS `t_items`;
CREATE TABLE `t_items` (
`itemid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`account` VARCHAR(15) NOT NULL DEFAULT '',
`content` VARCHAR(255) NOT NULL DEFAULT '',
`dateline` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`digg` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`reply` MEDIUMINT(5) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`itemid`),
KEY `uid` (`uid`)
) ENGINE=MYISAM;
DROP TABLE IF EXISTS `t_reply`;
CREATE TABLE `t_reply` (
`rid` MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
`replyto` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`uid` MEDIUMINT(8) NOT NULL DEFAULT '0',
`account` VARCHAR(15) NOT NULL DEFAULT '',
`content` VARCHAR(255) NOT NULL DEFAULT '',
`dateline` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`rid`),
KEY `uid` (`uid`),
KEY `replyto` (`replyto`)
) ENGINE=MYISAM;
DROP TABLE IF EXISTS `t_setting`;
CREATE TABLE `t_setting` (
`setname` VARCHAR(255) NOT NULL DEFAULT '',
`data` TEXT NOT NULL,
PRIMARY KEY (`setname`)
) ENGINE=MYISAM ;

SQL Error when creating a table

I have a problem when I run this SQL query:
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL )
The error I keep running into is the following:
Incorrect table definition;
there can be only one auto column and it must be defined as a key
Try this
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL ,
primary key (id) //specify id as primary key will sort out the error..try
)
OR Try
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL
)