MYSQL: Why I am not able create table - mysql

I am trying copy schema from one MYSQL database to other MYSQL database. While doing so few tables giving problem as follows
Error Code: 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 '(6) DEFAULT NULL,
`is_superuser` tinyint(1) NOT NULL,
`username` varchar(30)' at line 4
Execution Time : 0 sec
Transfer Time : 0 sec
Total Time : 0 sec
MYSQL SCRIPT
DROP TABLE IF EXISTS `auth_user`;
CREATE TABLE `auth_user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`password` VARCHAR(128) NOT NULL,
`last_login` DATETIME(6) DEFAULT NULL,
`is_superuser` TINYINT(1) NOT NULL,
`username` VARCHAR(30) NOT NULL,
`first_name` VARCHAR(30) NOT NULL,
`last_name` VARCHAR(30) NOT NULL,
`email` VARCHAR(254) NOT NULL,
`is_staff` TINYINT(1) NOT NULL,
`is_active` TINYINT(1) NOT NULL,
`date_joined` DATETIME(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=INNODB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1;

Change DATETIME TO TIMESTAMP:
like this:
CREATE TABLE `auth_user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`password` VARCHAR(128) NOT NULL,
`last_login` TIMESTAMP NOT NULL,
`is_superuser` TINYINT(1) NOT NULL,
`username` VARCHAR(30) NOT NULL,
`first_name` VARCHAR(30) NOT NULL,
`last_name` VARCHAR(30) NOT NULL,
`email` VARCHAR(254) NOT NULL,
`is_staff` TINYINT(1) NOT NULL,
`is_active` TINYINT(1) NOT NULL,
`date_joined` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=INNODB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1;

MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.You don't need to specify the length for datetime datatypes
DROP TABLE IF EXISTS `auth_user`;
CREATE TABLE `auth_user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`password` VARCHAR(128) NOT NULL,
`last_login` DATETIME DEFAULT NULL,
`is_superuser` TINYINT(1) NOT NULL,
`username` VARCHAR(30) NOT NULL,
`first_name` VARCHAR(30) NOT NULL,
`last_name` VARCHAR(30) NOT NULL,
`email` VARCHAR(254) NOT NULL,
`is_staff` TINYINT(1) NOT NULL,
`is_active` TINYINT(1) NOT NULL,
`date_joined` DATETIME NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=INNODB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1;

Related

Mysql Query Error 1054 - Unknown column in the 'field list'

I'm learning MYSQL FULL JOIN queries using the Northwind database. This is my query,
SELECT customers.CompanyName, orders.OrderID
FROM customers
FULL JOIN orders ON customers.CustomerID=orders.CustomerID
ORDER BY customers.CompanyName;
Customers table schema,
CREATE TABLE `customers` (
`CustomerID` varchar(5) NOT NULL,
`CompanyName` varchar(40) NOT NULL,
`ContactName` varchar(30) DEFAULT NULL,
`ContactTitle` varchar(30) DEFAULT NULL,
`Address` varchar(60) DEFAULT NULL,
`City` varchar(15) DEFAULT NULL,
`Region` varchar(15) DEFAULT NULL,
`PostalCode` varchar(10) DEFAULT NULL,
`Country` varchar(15) DEFAULT NULL,
`Phone` varchar(24) DEFAULT NULL,
`Fax` varchar(24) DEFAULT NULL,
`Image` longblob,
`ImageThumbnail` longblob,
PRIMARY KEY (`CustomerID`),
KEY `City` (`City`),
KEY `CompanyName` (`CompanyName`),
KEY `PostalCode` (`PostalCode`),
KEY `Region` (`Region`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Orders table schema,
CREATE TABLE `orders` (
`OrderID` int(11) NOT NULL AUTO_INCREMENT,
`CustomerID` varchar(5) DEFAULT NULL,
`EmployeeID` int(11) DEFAULT NULL,
`OrderDate` datetime DEFAULT NULL,
`RequiredDate` datetime DEFAULT NULL,
`ShippedDate` datetime DEFAULT NULL,
`ShipVia` int(11) DEFAULT NULL,
`Freight` decimal(19,4) DEFAULT '0.0000',
`ShipName` varchar(40) DEFAULT NULL,
`ShipAddress` varchar(60) DEFAULT NULL,
`ShipCity` varchar(15) DEFAULT NULL,
`ShipRegion` varchar(15) DEFAULT NULL,
`ShipPostalCode` varchar(10) DEFAULT NULL,
`ShipCountry` varchar(15) DEFAULT NULL,
PRIMARY KEY (`OrderID`),
KEY `CustomerID` (`CustomerID`),
KEY `EmployeeID` (`EmployeeID`),
KEY `OrderDate` (`OrderDate`),
KEY `ShippedDate` (`ShippedDate`),
KEY `ShipPostalCode` (`ShipPostalCode`)
) ENGINE=MyISAM AUTO_INCREMENT=11078 DEFAULT CHARSET=utf8;
And this is MySQL server version 5.7.35 - MySQL Community Server (GPL)
I am getting #1054 - Unknown column 'customers.CompanyName' in 'field list'
Can someone point out what I am doing wrong?
mysql don`t support full join,but oracle support
you can use
select customers.CompanyName, orders.OrderID from customers,orders where customers.CustomerID=orders.CustomerID order by
customers.CompanyName;

Sql error syntaxes with phpmyadmin

Good day,
I have an issue using the phpmyadmin for my database, I'm in new in this and this is the mysql structure from previewmysql:
CREATE TABLE `mydb`.`attendant`
(
`id` INT NOT NULL auto_increment,
`first_name` VARCHAR(20) NOT NULL,
`names` VARCHAR(50) NOT NULL,
`gender` ENUM(0) NOT NULL,
`email` VARCHAR(20) NOT NULL,
`phone` INT(15) NULL,
`marital_status` ENUM(0) NOT NULL,
`added_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`membership` ENUM(0) NOT NULL,
`address` VARCHAR(20) NOT NULL,
`suburb` ENUM(0) NOT NULL,
`partner_name` VARCHAR(25) NULL,
PRIMARY KEY (`id`),
UNIQUE `email_address` (`email`)
)
engine = innodb;
The error is:
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 '0) NOT NULL , `email` VARCHAR(20) NOT NULL , `phone` INT(15) NULL , `marital_sta' at line 1
And also attached is my phpmyadmin table structure.
Will appreciate any help.
Try it.Hope errors goes boom.I just fixed your errors. But your table structure is not good enough. give time, then day by day you will also be expert on it.
CREATE TABLE `mydb`.`attendant`
(
`id` INT NOT NULL auto_increment,
`first_name` VARCHAR(20) NOT NULL,
`names` VARCHAR(50) NOT NULL,
`gender` ENUM('0','1') NOT NULL,
`email` VARCHAR(20) NOT NULL,
`phone` INT(15),
`marital_status` ENUM('0','1') NOT NULL,
`added_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`membership` ENUM('0','1') NOT NULL,
`address` VARCHAR(20) NOT NULL,
`suburb` ENUM('0','1') NOT NULL,
`partner_name` VARCHAR(25) NULL,
PRIMARY KEY (`id`),
UNIQUE `email_address` (`email`)
)
engine = innodb;
Modify ENUM declaration as ENUM ('male', 'female') for gender column and others also as shown in your table. It will not accept ENUM(0).
ENUM(0) is wrong format , if you want that for gender roles then you can use :-
ENUM('Male', 'Female') i.e you can run this query :-
CREATE TABLE `mydb`.`attendant`
(
`id` INT NOT NULL auto_increment,
`first_name` VARCHAR(20) NOT NULL,
`names` VARCHAR(50) NOT NULL,
`gender` ENUM('Male', 'Female') NOT NULL,
`email` VARCHAR(20) NOT NULL,
`phone` INT(15) NULL,
`marital_status` ENUM('Single','Married','divorced') NOT NULL,
`added_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`membership` ENUM('no','yes') NOT NULL,
`address` VARCHAR(20) NOT NULL,
`suburb` ENUM('Cape Town','Woodstock') NOT NULL,
`partner_name` VARCHAR(25) NULL,
PRIMARY KEY (`id`),
UNIQUE `email_address` (`email`)
)
engine = innodb;
You have used ENUM data type in your table. And provided 0 as argument but
An enumeration value must be a quoted string literal
You can refer the mySql documentation for more information
http://dev.mysql.com/doc/refman/5.7/en/enum.html

Two MySql tables have correct indexes yet JOIN takes 9 seconds on small tables

mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
I am taking over a project. It is very old and the original programmer is long gone. No one has any idea why certain decisions were made.
The following query runs (on my Mac) in 9.5 seconds but if I remove the last JOIN then it drops to 2.5 seconds. What is wrong with that last JOIN?
select `ttl`.`id` AS `id`,
`ttl`.`name` AS `name`,
`ttl`.`updated_at` AS `last_update_on`,
`ttl`.`user_id` AS `list_creator`,
`ttl`.`retailer_nomination_list` AS `nomination_list`,
`ttl`.`created_at` AS `created_on`,
count(distinct `tlb`.`title_id`) AS `title_count`
from `haha_title_lists` `ttl`
left join `haha_title_list_to_users` `tltu` on((`ttl`.`id` = `tltu`.`title_list_id`))
left join `users` `u` on((`tltu`.`user_id` = `u`.`id`))
left join `users` `u2` on((`tltu`.`user_id` = `u2`.`id`))
left join `haha_title_list_to_venues` `tlv` on((`ttl`.`id` = `tlv`.`title_list`))
left join `haha_venue_properties` `tvp` on((`tlv`.`venue_id` = `tvp`.`id`))
join `haha_title_list_to_books` `tlb` on((`ttl`.`id` = `tlb`.`title_list_id`))
join `wawa_title` `ot` on((`tlb`.`title_id` = `ot`.`title_id`))
group by `ttl`.`id`;
The tables:
CREATE TABLE `haha_title_list_to_books` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title_id` int(11) NOT NULL,
`title_list_id` int(11) NOT NULL,
`sdk` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`created_at` datetime NOT NULL,
`promo_start_date` date DEFAULT NULL,
`promo_end_date` date DEFAULT NULL,
`promo_price` float DEFAULT NULL,
`confirmations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`nominations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`title_note` text COLLATE utf8_unicode_ci,
`executed` int(11) DEFAULT NULL,
`event_created` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_promo_start_date` (`promo_start_date`),
KEY `idx_promo_end_date` (`promo_end_date`),
KEY `idx_title_list_to_books_title_id` (`title_id`),
KEY `idx_title_list_to_books_title_list_id` (`title_list_id`)
) ENGINE=MyISAM AUTO_INCREMENT=21847 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
and:
CREATE TABLE `wawa_title` (
`title_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`title_alpha` varchar(25) NOT NULL,
`display_title` varchar(200) NOT NULL,
`subtitle` text NOT NULL,
`sdk10` varchar(13) DEFAULT '',
`sdk13` varchar(15) DEFAULT NULL,
`primary_sdk13` varchar(15) DEFAULT NULL,
`asin` varchar(10) DEFAULT NULL,
`pub_season` varchar(15) NOT NULL,
`pub_year` varchar(15) NOT NULL,
`bisac1` varchar(15) NOT NULL,
`bisac2` varchar(15) NOT NULL,
`bisac3` varchar(15) NOT NULL,
`barcode` varchar(30) DEFAULT NULL,
`dewey_decimal` varchar(15) NOT NULL,
`lib_of_congress` varchar(15) NOT NULL,
`spanish_language` tinyint(4) NOT NULL,
`target_audience` tinyint(3) unsigned DEFAULT NULL,
`language` varchar(20) DEFAULT NULL,
`edition` varchar(45) DEFAULT NULL,
`pages` int(11) DEFAULT NULL,
`number_in_series` int(11) DEFAULT NULL,
`trimsize` varchar(10) DEFAULT NULL,
`filesize` varchar(10) DEFAULT NULL,
`duration_hours` int(11) DEFAULT NULL,
`duration_minutes` int(11) DEFAULT NULL,
`discs` int(11) DEFAULT NULL,
`download` date DEFAULT NULL,
`size_unit` varchar(15) NOT NULL DEFAULT '',
`digitization_date` date NOT NULL,
`us_on_sale_date` date NOT NULL,
`aus_on_sale_date` date NOT NULL,
`can_on_sale_date` date NOT NULL,
`uk_on_sale_date` date NOT NULL,
`us_list_price` varchar(10) NOT NULL,
`aus_list_price` varchar(10) NOT NULL,
`can_list_price` varchar(10) NOT NULL,
`uk_list_price` varchar(10) NOT NULL,
`isPrimary` varchar(1) DEFAULT NULL,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modifier` int(11) NOT NULL,
`activated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` varchar(3) NOT NULL DEFAULT 'N',
`flagged_string` text,
`created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`assets_id` varchar(20) DEFAULT NULL,
`book_details` text,
`book_keynote` text,
`exclude_goodreads` char(1) NOT NULL DEFAULT 'N',
`series_description` text,
`review_quote1` text,
`territory_id` int(11) DEFAULT '27',
`featured_newsletter_id` tinyint(3) unsigned DEFAULT '0',
`retailer_discovery_check` datetime DEFAULT NULL,
`suppress_retailer_approval` tinyint(1) DEFAULT '0',
`suppress_retailer_approval_reason` varchar(255) DEFAULT NULL,
`ebb_description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`slug` varchar(150) DEFAULT NULL,
`legacy_slug` varchar(150) DEFAULT NULL,
`us_agency_price` varchar(10) DEFAULT NULL,
`firebrand_title_id` int(11) DEFAULT NULL,
`ebb_label` varchar(200) DEFAULT NULL,
`ebb_end_sale_date` date DEFAULT NULL,
`ebb_downprice` decimal(10,2) DEFAULT NULL,
`book_club` varchar(1) DEFAULT NULL,
`best_seller` varchar(1) DEFAULT NULL,
`award_winner` varchar(1) DEFAULT NULL,
`discovery` char(1) NOT NULL DEFAULT 'Y',
`narrator_id` int(11) DEFAULT NULL,
`suppress_series_data` varchar(255) DEFAULT NULL,
PRIMARY KEY (`title_id`),
KEY `active_index` (`active`),
KEY `fk_title_series_id_idx` (`series_id`),
KEY `series_id` (`series_id`),
KEY `idx_title_sdk13` (`sdk13`),
KEY `idx_title_active_isprimary` (`active`,`isPrimary`),
KEY `bisac1` (`bisac1`),
KEY `bisac2` (`bisac2`),
KEY `bisac3` (`bisac3`),
KEY `idx_primary_sdk13` (`primary_sdk13`),
KEY `idx_territory_id` (`territory_id`),
CONSTRAINT `fk_title_series_id` FOREIGN KEY (`series_id`) REFERENCES `wawa_series` (`series_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=19700 DEFAULT CHARSET=utf8 |
If I remove this line:
join `wawa_title` `ot` on((`tlb`.`title_id` = `ot`.`title_id`))
The query speed drops from 9.5 seconds to 2.5 seconds. Not great, but a huge improvement.
And yet, both tables have indexes on table_id, so why would that line be a problem?
I notice that one table is InnoDB and the other is MyISAM. Would that have an effect?
Do not JOIN to tables that you don't use.
A JOIN often "explodes" the number of rows, then a GROUP BY like you have reels in the number of rows. To see this, leave all the JOINs there, but remove the GROUP BY. See how many rows you get.
To avoid part of that explosion, change
count(distinct `tlb`.`title_id`) AS `title_count`
to
( SELECT count(distinct `title_id`)
FROM `haha_title_list_to_books`
WHERE `ttl`.`id` = `title_list_id`
) AS `title_count`
and remove the current JOIN to tlb.
Mixing MyISAM and InnoDB should not have any direct impact on this SELECT. However, you should consider moving all of your tables to InnoDB.

Mysql error 1215 - Cannot add foreign key constraint

Created these two tables successfully
First table
CREATE TABLE IF NOT EXISTS `lawncare_user` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,
`Email` varchar(255) NOT NULL,
`UserType` varchar(30) NOT NULL,
`UserName` varchar(255) NOT NULL,
`Password` varchar(255) NOT NULL,
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
`ModifiedOn` date DEFAULT NULL,
`Status` BOOLEAN NOT NULL DEFAULT '0',
`QuestionID` int(11) DEFAULT NULL,
`QuestionAnswer` text DEFAULT NULL,
`Params` text NOT NULL,
`Address` text NOT NULL,
`Country` varchar(300) NOT NULL,
`State` varchar(300) NOT NULL,
`City` varchar(300) NOT NULL,
`ContactNo` double DEFAULT NULL,
`Activation` BOOLEAN NOT NULL DEFAULT '0',
`ActivatedOn` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Second table
CREATE TABLE IF NOT EXISTS `lawncare_customer` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,
`Email` varchar(255) NOT NULL,
`Password` varchar(255) NOT NULL,
`ContactNo` varchar(20) NOT NULL,
`Address` varchar(255) NOT NULL,
`Params` text NOT NULL,
`Province` varchar(255) NOT NULL,
`ZipCode` varchar(255) NOT NULL,
`Status` Boolean NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
`ModifiedOn` date DEFAULT NULL
) ENGINE =InnoDB DEFAULT CHARSET=latin1;
But while creating third table as
CREATE TABLE IF NOT EXISTS `lawncare_message` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Reason` int(5) NOT NULL,
`Subject` text NOT NULL,
`Description` text NOT NULL,
`Customer` int(11) NOT NULL,
`CustomerUser` varchar(255) NOT NULL,
`CustomerEmail` varchar(255) NOT NULL,
`SendTo` int(11) NOT NULL,
`SendToUser` varchar(255) NOT NULL,
`SendToEmail` varchar(255) NOT NULL,
`Status` int(5) NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL
FOREIGN KEY (SendTo, SendToUser, SendToEmail)
REFERENCES lawncare_user(ID, UserName, Email)
ON UPDATE CASCADE ,
FOREIGN KEY (Customer, CustomerUser, CustomerEmail)
REFERENCES lawncare_customer(ID, FirstName,Email)
ON UPDATE CASCADE
) ENGINE =InnoDB DEFAULT CHARSET=latin1
I get #1215 - Cannot add foreign key constraint , error in mysql tried adding foreign keys after creating table but it still gives the same error. I don't know what I'm doing wrong here.
First of all Check whether you have applied indexes on the keys.
As per your code their is no point in referencing id,UserName and Email.
Only id is enough for referencing.
Check the following code
CREATE TABLE IF NOT EXISTS `lawncare_message` (
`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Reason` int(5) NOT NULL,
`Subject` text NOT NULL,
`Description` text NOT NULL,
`Customer` int(11) NOT NULL,
`CustomerUser` varchar(255) NOT NULL,
`CustomerEmail` varchar(255) NOT NULL,
`SendTo` int(11) NOT NULL,
`SendToUser` varchar(255) NOT NULL,
`SendToEmail` varchar(255) NOT NULL,
`Status` int(5) NOT NULL DEFAULT '0',
`AddedBy` int(11) NOT NULL,
`AddedOn` date NOT NULL,
FOREIGN KEY (SendTo)
REFERENCES lawncare_user(ID)
ON UPDATE CASCADE ,
FOREIGN KEY (Customer)
REFERENCES lawncare_customer(ID)
ON UPDATE CASCADE
) ENGINE =InnoDB DEFAULT CHARSET=latin1

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xxx' for key 'group_key'

On my web page there is no insert or update but already to this I'm getting this error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-Bekoo-2449.10' for key 'group_key'
This is surprising because the web page does not modify any rows, and the Product table does not have a group_key column or key.
My query :
SELECT Product._like,
comment_count,
title,
price_lower,
price,image,
AffiliateOffers.name,
p‌​‌​ayout_yuzde,
payout_nakit,
payout_type,
xml_id,
brand,model,
currency,url,
Product.af‌​f_‌​id,
Product.offer_id,
pb_share_1,
pb_share_2,
pb_share_1_payda,
pb_share_2_payda,
A‌​ffil‌​iateOffers.seo_title,
afo_offer_id,
r_category,
seo_description
FROM Product
inner Join AffiliateOffers on Product.aff_id = AffiliateOffers.af_id
AND Product.offer_id = AffiliateOffers.af_offer_id
where Product.status = 1
and Product.aff_id = 1
and Product.offer_id = 1290
and my table structure :
` CREATE TABLE `_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`xml_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`aff_id` int(11) NOT NULL,
`offer_id` int(11) NOT NULL,
`r_category` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`category_id1` int(11) NOT NULL,
`category_id2` int(11) NOT NULL,
`category_id3` int(11) NOT NULL,
`brand` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`model` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL,
`title` mediumtext COLLATE utf8_unicode_ci NOT NULL,
`description_1` mediumtext COLLATE utf8_unicode_ci,
`price` decimal(18,2) NOT NULL,
`price_lower` decimal(18,2) NOT NULL,
`percentage_lower` int(11) NOT NULL,
`image` mediumtext COLLATE utf8_unicode_ci NOT NULL,
`url` text COLLATE utf8_unicode_ci,
`feature` tinyint(4) NOT NULL,
`city` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
`sex` tinyint(4) NOT NULL,
`stock` tinyint(4) NOT NULL,
`start_date` int(25) NOT NULL,
`finish_date` int(25) NOT NULL,
`update_date` int(25) NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '1',
`hit` int(11) NOT NULL DEFAULT '1',
`_like` int(11) NOT NULL DEFAULT '0',
`comment_count` int(11) DEFAULT NULL,
`like_count` int(11) DEFAULT NULL,
`lastlike_time` int(25) DEFAULT NULL,
`visit_count` int(11) DEFAULT NULL,
`lastvisit_count` int(25) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `xml_id` (`xml_id`),
KEY `lastlike_time` (`lastlike_time`),
KEY `offer_id` (`offer_id`),
KEY `r_category` (`r_category`),
KEY `status` (`status`)
) ENGINE=MyISAM AUTO_INCREMENT=3816867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci`
Why am I getting this error?
Unless you say otherwise, group_key is an internal field used by MySQL when aggregating things so you won't find it in your own tables or view. A duplicate entry error in there means you've got some sort of problem with your aggregation.
Have a look at any GROUP BY statements you're using, and ensure you've got their syntax correct, particularly in any aggregate functions and group expressions.
In Phpmyadmin you have to truncate all the logtables.
That should fix it.
I ran into the same problem, i was forgotten to clear the visitor and online log.
Both of the tables are generate a log/id for the user ( thats where the XXX for stands )
If you truncate both of the tables it will fix this problem.