Error in MySQL database code while importing - mysql

my code :
CREATE TABLE IF NOT EXISTS `friends` (
`Id` INT(10) NOT NULL AUTO_INCREMENT,
`providerid` INT(10) NOT NULL AUTO_INCREMENT,
`requestid` INT(10) NOT NULL AUTO_INCREMENT,
`status` BINARY(1) NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `messages` (
`Id` INT(255) NOT NULL AUTO_INCREMENT,
`fromuid` INT(255) NOT NULL,
`touid` INT(255) NOT NULL,
`sentdt` DATETIME NOT NULL,
`read` TINYINT(1) NOT NULL DEFAULT '0',
`readdt` DATETIME DEFAULT NULL,
`messagetext` LONGTEXT CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `users` (
`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` VARCHAR(45) NOT NULL DEFAULT '',
`password` VARCHAR(32) NOT NULL DEFAULT '',
`email` VARCHAR(45) NOT NULL DEFAULT '',
`date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`authenticationTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`userKey` VARCHAR(32) NOT NULL DEFAULT '',
`IP` VARCHAR(45) NOT NULL DEFAULT '',
`port` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`)
);
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 'CREATE TABLE IF NOT EXISTS messages (
Id int(255) NOT NULL AUTO_INCREMENT,' at line 8
so plz help me correcting the code...
Thank you

There are few errors in your script.
1) there can be only one autoincrement key and it must be defined as a key
2) spelling mistable in third query of DEFAULT in
`email` varchar(45) NOT NULL DEFAULT '',
3) DEFAULT keyword used twice in 3rd query for below field and missing NULL for NOT NULL
`authenticationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
CORRECT query:-
CREATE TABLE IF NOT EXISTS `friends` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`providerid` int(10) NOT NULL ,
`requestid` int(10) NOT NULL ,
`status` binary(1) NOT NULL ,
PRIMARY KEY (`Id`));
CREATE TABLE IF NOT EXISTS `messages` (
`Id` int(255) NOT NULL AUTO_INCREMENT,
`fromuid` int(255) NOT NULL,
`touid` int(255) NOT NULL,
`sentdt` datetime NOT NULL,
`read` tinyint(1) NOT NULL DEFAULT '0',
`readdt` datetime DEFAULT NULL,
`messagetext` longtext CHARACTER SET utf8 NOT NULL ,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `users` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(45) NOT NULL DEFAULT '',
`password` varchar(32) NOT NULL DEFAULT '',
`email` varchar(45) NOT NULL DEFAULT '',
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` tinyint(3) unsigned NOT NULL DEFAULT '0',
`authenticationTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`userKey` varchar(32) NOT NULL DEFAULT '',
`IP` varchar(45) NOT NULL DEFAULT '',
`port` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`)
)

Related

You have an error in your SQL syntax; syntax to use near 'CREATE TABLE `users` ( `id` INT(11) NULL AUTO_INCREMENT, `hex_id` VARCHAR(10' at line 25

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 'CREATE TABLE users ( id INT(11) NULL AUTO_INCREMENT, hex_id VARCHAR(10' at line 25
CREATE TABLE `characters` (
`id` INT(11) NULL AUTO_INCREMENT,
`owner` VARCHAR(50) DEFAULT NULL,
`first_name` VARCHAR(50) NOT NULL DEFAULT 'John',
`last_name` VARCHAR(50) NOT NULL DEFAULT 'Doe',
`date_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
`cash` INT(9) DEFAULT 500,
`bank` INT(9) NOT NULL DEFAULT 5000,
`phone_number` BIGINT(11) NOT NULL DEFAULT 0,
`dob` DATE NOT NULL DEFAULT '0000-00-00',
`story` TEXT NOT NULL,
`new` INT(1) NOT NULL DEFAULT 1,
`deleted` INT(11) NOT NULL DEFAULT 0,
`deletion_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`gender` INT(1) NOT NULL DEFAULT 0,
`jail_time` INT(11) NOT NULL DEFAULT 0,
`dirty_money` INT(11) NOT NULL DEFAULT 0,
`gang_type` INT(11) NOT NULL DEFAULT 0,
`jail_time_mobster` INT(11) NOT NULL DEFAULT 0,
`judge_type` INT(11) NOT NULL DEFAULT 0,
`iswjob` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
CREATE TABLE `users` (
`id` INT(11) NULL AUTO_INCREMENT,
`hex_id` VARCHAR(100) DEFAULT NULL,
`steam_id` VARCHAR(50) DEFAULT NULL,
`community_id` VARCHAR(100) DEFAULT NULL,
`license` VARCHAR(255) DEFAULT NULL,
`name` VARCHAR(255) NOT NULL DEFAULT 'Uknown',
`ip` VARCHAR(50) NOT NULL DEFAULT 'Uknown',
`rank` VARCHAR(50) NOT NULL DEFAULT 'user',
`date_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (id)
);
CREATE TABLE `users_whitelist` (
`id` INT(11) NULL AUTO_INCREMENT,
`steam_id` VARCHAR(50) DEFAULT NULL,
`power` INT(11) NOT NULL DEFAULT 0,
`admin_name` TEXT NOT NULL,
`user_name` TEXT NOT NULL,
`user_ip` TEXT NOT NULL,
PRIMARY KEY (id)
);
id should be not null
`id` INT(11) NOT NULL AUTO_INCREMENT,
Create Table class
(
Class_no in not null auto_increment,
Class_name varchar(50) not null,
Lev_no varchar(50)not null,
Index_index_add (cl_name,lev_no)
)

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

Indexes in Mysql table

I have such tables:
CREATE TABLE `skadate_newsfeed_action` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`entityId` int(11) NOT NULL,
`entityType` varchar(100) NOT NULL,
`feature` varchar(100) NOT NULL,
`data` longtext NOT NULL,
`status` varchar(20) NOT NULL DEFAULT 'active',
`createTime` int(11) NOT NULL,
`updateTime` int(11) NOT NULL,
`userId` int(11) NOT NULL,
`visibility` int(11) NOT NULL,
`privacy` enum('everybody','friends_only') NOT NULL DEFAULT 'everybody',
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
KEY `privacy` (`visibility`),
KEY `updateTime` (`updateTime`),
KEY `entity` (`entityType`,`entityId`)
) ENGINE=MyISAM;
CREATE TABLE `skadate_profile` (
`profile_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(128) NOT NULL DEFAULT '',
`username` varchar(32) NOT NULL DEFAULT '',
`password` varchar(40) NOT NULL,
`sex` bigint(20) DEFAULT NULL,
`match_sex` bigint(20) DEFAULT NULL,
`birthdate` date NOT NULL DEFAULT '0000-00-00',
`headline` varchar(128) DEFAULT '',
`general_description` text,
`match_agerange` varchar(6) DEFAULT NULL,
`custom_location` varchar(255) DEFAULT NULL,
`country_id` char(2) NOT NULL DEFAULT '',
`zip` varchar(10) DEFAULT NULL,
`state_id` varchar(5) DEFAULT NULL,
`city_id` int(11) DEFAULT '0',
`join_stamp` int(10) unsigned NOT NULL DEFAULT '0',
`activity_stamp` int(10) unsigned NOT NULL DEFAULT '0',
`membership_type_id` int(10) unsigned NOT NULL DEFAULT '18',
`affiliate_id` int(8) unsigned NOT NULL DEFAULT '0',
`email_verified` enum('undefined','yes','no') NOT NULL DEFAULT 'undefined',
`reviewed` enum('n','y') NOT NULL DEFAULT 'n',
`has_photo` enum('n','y') NOT NULL DEFAULT 'n',
`has_media` enum('n','y') NOT NULL DEFAULT 'n',
`status` enum('active','on_hold','suspended') NOT NULL DEFAULT 'active',
`featured` enum('n','y') NOT NULL DEFAULT 'n',
`register_invite_score` tinyint(3) NOT NULL DEFAULT '0',
`rate_score` tinyint(3) unsigned NOT NULL DEFAULT '0',
`rates` bigint(20) unsigned NOT NULL DEFAULT '0',
`language_id` int(10) unsigned NOT NULL DEFAULT '0',
`join_ip` int(11) unsigned NOT NULL DEFAULT '0',
`neigh_location` enum('country','state','city','zip') DEFAULT NULL,
`neigh_location_distance` int(10) unsigned NOT NULL DEFAULT '0',
`bg_color` varchar(32) DEFAULT NULL,
`bg_image` varchar(32) DEFAULT NULL,
`bg_image_url` varchar(255) DEFAULT NULL,
`bg_image_mode` tinyint(1) DEFAULT NULL,
`bg_image_status` enum('active','approval') NOT NULL DEFAULT 'active',
`has_music` enum('n','y') NOT NULL DEFAULT 'n',
`is_private` tinyint(1) NOT NULL DEFAULT '0',
`subscription_id_offerit` text,
PRIMARY KEY (`profile_id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `username` (`username`),
KEY `membership_id` (`membership_type_id`),
KEY `zip` (`zip`),
KEY `country_id` (`country_id`),
KEY `state_id` (`state_id`),
KEY `city_id` (`city_id`),
KEY `sex` (`sex`),
KEY `match_sex` (`match_sex`),
KEY `activity_stamp` (`activity_stamp`),
KEY `join_stamp` (`join_stamp`),
KEY `birthdate` (`birthdate`),
KEY `featured` (`featured`,`has_photo`,`activity_stamp`)
) ENGINE=MyISAM;
And try to perform this query:
SELECT DISTINCT `na`.*
FROM `skadate_newsfeed_action` AS `na`
LEFT JOIN `skadate_profile` AS `profile` ON ( `na`.`userId` = `profile`.`profile_id` )
WHERE ( profile.email_verified='yes' OR profile.email_verified='no' OR profile.email_verified='undefined' )
AND `profile`.`status`='active' AND `na`.`status`='active' AND `na`.`privacy`='everybody'
AND `na`.`visibility` & 1 AND `na`.`updateTime` < 1455885224
ORDER BY `na`.`updateTime` DESC, `na`.`id` DESC
LIMIT 0, 10
But when I see EXPLAIN:
Maybe someone can help me, how I can improve this query?
If you want records from only one table, then use exists rather than a join and select distinct. So:
SELECT na.*
FROM `skadate_newsfeed_action` na
WHERE EXISTS (SELECT 1
FROM skadate_profile p
WHERE na.userId = p.profile_id AND
p.email_verified IN ('yes', 'no', 'undefined') AND
p.status = 'active'
) AND
na.status = 'active' AND
na.privacy = 'everybody' AND
na.visibility & 1 > 0 AND
na.updateTime < 1455885224
ORDER BY na.`updateTime` DESC, na.`id` DESC
LIMIT 0, 10;
For this query, you want an index on skadate_profile(profile_id, status, verified). Also, the following index is probably helpful: skadate_newsfeed_action(status, privacy, updateTime, visibility, userId).
This is probably because of the DISTICT keyword. To remove duplicates MySQL needs to sort the result by every selected column.

#1060 - Duplicate column name 'ID' Why?

CREATE TABLE IF NOT EXISTS `vehicles` (
`UID` int(4) NOT NULL,
`id` int(11) NOT NULL,
`Kofferraum` varchar(50) NOT NULL DEFAULT '0|0|0|0|',
`Typ` int(11) NOT NULL,
`Tuning` varchar(255) NOT NULL,
`Spawnpos_X` varchar(50) NOT NULL,
`Spawnpos_Y` varchar(50) NOT NULL,
`Spawnpos_Z` varchar(50) NOT NULL,
`Spawnrot_X` varchar(50) NOT NULL,
`Spawnrot_Y` varchar(50) NOT NULL,
`Spawnrot_Z` varchar(50) NOT NULL,
`Farbe` varchar(50) NOT NULL,
`Paintjob` varchar(50) NOT NULL DEFAULT '3',
`Benzin` varchar(50) NOT NULL DEFAULT '100',
`Slot` float NOT NULL,
`Special` int(11) NOT NULL DEFAULT '0',
`Lights` varchar(50) NOT NULL DEFAULT '|255|255|255|',
`Distance` double NOT NULL DEFAULT '0',
`STuning` varchar(50) NOT NULL DEFAULT '0|0|0|0|0|0|',
`AuktionsID` int(10) NOT NULL DEFAULT '0',
`GangVehicle` tinyint(1) NOT NULL DEFAULT '0',
`rc` int(1) NOT NULL DEFAULT '0',
`spezcolor` varchar(50) NOT NULL DEFAULT '|0|0|0|0|0|0|',
`Sportmotor` int(1) NOT NULL DEFAULT '0',
`Bremse` varchar(1) NOT NULL DEFAULT '0',
`Antrieb` varchar(10) NOT NULL,
`plate` text NOT NULL,
`ID` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Because you're using 'id' twice. Either remove the duplicate or change the name of this to something else:
ID int(11) NOT NULL
You have the column id twice. Once at the beginning an one at the end.
CREATE TABLE IF NOT EXISTS `vehicles` (
`UID` int(4) NOT NULL,
`id` int(11) NOT NULL,
...
`ID` int(11) NOT NULL,
PRIMARY KEY (`ID`)
...
remove one of them

MySQL syntax error I don't understand [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
MySQL generated by a dump of a v3.23.58 database:
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`DATE` date NOT NULL default '0000-00-00',
`SECTION_ID` smallint(6) NOT NULL default '0',
`PRIORITY` int(11) NOT NULL default '0',
`AUTHOR1` int(100) NOT NULL default '1',
`AUTHOR2` varchar(100) NOT NULL default '',
`AUTHOR3` varchar(100) NOT NULL default '',
`AUTHOR4` varchar(100) NOT NULL default '',
`AUTHOR5` varchar(100) NOT NULL default '',
`AUTHOR6` int(100) NOT NULL default '0',
`AUTHOR7` int(100) NOT NULL default '0',
`AUTHOR8` int(100) NOT NULL default '0',
`AUTHOR9` int(100) NOT NULL default '0',
`AUTHOR10` int(100) NOT NULL default '0',
`AUTHOR_JOB` int(11) NOT NULL default '0',
`TITLE` varchar(100) NOT NULL default '',
`SUBHEAD` varchar(200) NOT NULL default '',
`TEXT` text NOT NULL,
`PULLQUOTE` text NOT NULL,
`SERIES` int(10) unsigned zerofill NOT NULL default '0000000000',
`TYPE` int(10) unsigned zerofill NOT NULL default '0000000000',
`VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
`EMAILS` int(10) unsigned zerofill NOT NULL default '0000000000',
`BACKUPTEXT` text NOT NULL,
`BOWDOIN_VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
PRIMARY KEY (`DATE`,`SECTION_ID`,`PRIORITY`),
FULLTEXT KEY `article_full_text` (`TITLE`,`TEXT`)
) TYPE=MyISAM;
Attempting to import it into a v5.5.19 database, I get this error:
[ERROR in query 2] 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 'TYPE=MyISAM' at line 28
I've tried deconstructing it to a very basis skeleton but still get the error. Ought to be an obvious mistake if you have the eye for it.
Your version of MySQL probably requires that you edit query
replace
TYPE=MyISAM
with
ENGINE=MyISAM
if you are importing from script file then just:
Open script file
Find TYPE=MyISAM
Replace with ENGINE=MyISAM
save
Then try .
change last line
) TYPE=MyISAM;
to
) ENGINE=MyISAM
so all would be
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`DATE` date NOT NULL default '0000-00-00',
`SECTION_ID` smallint(6) NOT NULL default '0',
`PRIORITY` int(11) NOT NULL default '0',
`AUTHOR1` int(100) NOT NULL default '1',
`AUTHOR2` varchar(100) NOT NULL default '',
`AUTHOR3` varchar(100) NOT NULL default '',
`AUTHOR4` varchar(100) NOT NULL default '',
`AUTHOR5` varchar(100) NOT NULL default '',
`AUTHOR6` int(100) NOT NULL default '0',
`AUTHOR7` int(100) NOT NULL default '0',
`AUTHOR8` int(100) NOT NULL default '0',
`AUTHOR9` int(100) NOT NULL default '0',
`AUTHOR10` int(100) NOT NULL default '0',
`AUTHOR_JOB` int(11) NOT NULL default '0',
`TITLE` varchar(100) NOT NULL default '',
`SUBHEAD` varchar(200) NOT NULL default '',
`TEXT` text NOT NULL,
`PULLQUOTE` text NOT NULL,
`SERIES` int(10) unsigned zerofill NOT NULL default '0000000000',
`TYPE` int(10) unsigned zerofill NOT NULL default '0000000000',
`VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
`EMAILS` int(10) unsigned zerofill NOT NULL default '0000000000',
`BACKUPTEXT` text NOT NULL,
`BOWDOIN_VIEWS` int(10) unsigned zerofill NOT NULL default '0000000000',
PRIMARY KEY (`DATE`,`SECTION_ID`,`PRIORITY`),
FULLTEXT KEY `article_full_text` (`TITLE`,`TEXT`)
) ENGINE=MyISAM;