correct mysql syntax error - mysql

please could someone tell me the problem with this syntax because mysql 5.5.32 keeps tell me about an error
CREATE TABLE `clients` (
`ID` tinyint(11) NOT NULL auto_increment,
`title` varchar(10) NOT NULL default '',
`firstName` varchar(30) NOT NULL default '',
`lastName` varchar(30) NOT NULL default '',
`address1` varchar(100) NOT NULL default '',
`address2` varchar(100) NOT NULL default '',
`town` varchar(100) NOT NULL default '',
`province` varchar(100) NOT NULL default '',
`country` varchar(40) NOT NULL default '',
`postCode` varchar(20) NOT NULL default '',
`telephone` varchar(20) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`cardNo` varchar(16) NOT NULL default '0000-00-00',
`expiryDate` date NOT NULL default '0000-00-00',
PRIMARY KEY (`ID`)
) TYPE=MyISAM COMMENT='customer table' AUTO_INCREMENT=1 ;

The keyword TYPE has been replaced by ENGINE as in
ENGINE=MyISAM

change TYPE to ENGINE like this:
CREATE TABLE `clients` (
`ID` tinyint(11) NOT NULL auto_increment,
`title` varchar(10) NOT NULL default '',
`firstName` varchar(30) NOT NULL default '',
`lastName` varchar(30) NOT NULL default '',
`address1` varchar(100) NOT NULL default '',
`address2` varchar(100) NOT NULL default '',
`town` varchar(100) NOT NULL default '',
`province` varchar(100) NOT NULL default '',
`country` varchar(40) NOT NULL default '',
`postCode` varchar(20) NOT NULL default '',
`telephone` varchar(20) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`cardNo` varchar(16) NOT NULL default '0000-00-00',
`expiryDate` date NOT NULL default '0000-00-00',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM COMMENT='customer table' AUTO_INCREMENT=1 ;
MySQL 5.0 accepts TYPE or ENGINE, but above MySQL 5.1, Only ENGINE is allowed.

Related

need help Mysql query

I am trying to achieve displaying a field in my database.
basically at the moment i have
'SELECT
historylist.artist,
historylist.ID,
artistlist.lyrics,
artistlist.ID
FROM historylist
INNER JOIN artistlist
ON historylist.ID = artistlist.ID
ORDER BY historylist.date_played DESC
LIMIT 1;'
Now this is not correct. I need to use the history list ID to link the artistlist ID. Then grab the field artistlist.lyrics. then display it. Right now when i do it like that it shows the lyrics field but its null. So i am guessing its searching historylist table
CREATE TABLE `historylist` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`songID` int(11) NOT NULL DEFAULT '0',
`filename` varchar(255) NOT NULL DEFAULT '',
`date_played` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`duration` int(11) NOT NULL DEFAULT '0',
`artist` varchar(255) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`album` varchar(255) NOT NULL DEFAULT '',
`albumyear` varchar(4) NOT NULL DEFAULT '',
`website` varchar(255) NOT NULL DEFAULT '',
`buycd` varchar(255) NOT NULL DEFAULT '',
`picture` varchar(255) NOT NULL DEFAULT '',
`listeners` mediumint(9) NOT NULL DEFAULT '0',
`label` varchar(100) NOT NULL DEFAULT '',
`pline` varchar(50) NOT NULL DEFAULT '',
`trackno` int(11) NOT NULL DEFAULT '0',
`composer` varchar(100) NOT NULL DEFAULT '',
`ISRC` varchar(50) NOT NULL DEFAULT '',
`catalog` varchar(50) NOT NULL DEFAULT '',
`UPC` varchar(50) NOT NULL DEFAULT '',
`feeagency` varchar(20) NOT NULL DEFAULT '',
PRIMARY KEY (`ID`),
KEY `date_played` (`date_played`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
that code above is the historylist table
this one is the
CREATE TABLE IF NOT EXISTS `artistlist` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`filename` varchar(255) NOT NULL DEFAULT '',
`diskID` int(11) NOT NULL DEFAULT '0',
`flags` varchar(10) NOT NULL DEFAULT 'NNNNNNNNNN',
`songtype` char(1) NOT NULL DEFAULT 'S',
`status` tinyint(4) NOT NULL DEFAULT '0',
`weight` double NOT NULL DEFAULT '50',
`balance` double NOT NULL DEFAULT '0',
`date_added` datetime DEFAULT NULL,
`date_played` datetime DEFAULT NULL,
`date_artist_played` datetime DEFAULT '2002-01-01 00:00:01',
`date_album_played` datetime DEFAULT '2002-01-01 00:00:01',
`date_title_played` datetime DEFAULT '2002-01-01 00:00:01',
`duration` int(11) NOT NULL DEFAULT '0',
`artist` varchar(255) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`album` varchar(255) NOT NULL DEFAULT '',
`label` varchar(255) NOT NULL DEFAULT '',
`pline` varchar(50) NOT NULL DEFAULT '',
`trackno` int(11) NOT NULL DEFAULT '0',
`composer` varchar(100) NOT NULL DEFAULT '',
`ISRC` varchar(50) NOT NULL DEFAULT '',
`catalog` varchar(50) NOT NULL DEFAULT '',
`UPC` varchar(50) NOT NULL DEFAULT '',
`feeagency` varchar(20) NOT NULL DEFAULT '',
`albumyear` varchar(4) NOT NULL DEFAULT '0',
`genre` varchar(20) NOT NULL DEFAULT '',
`website` varchar(255) NOT NULL DEFAULT '',
`buycd` varchar(255) NOT NULL DEFAULT '',
`info` text,
`lyrics` text,
`picture` varchar(255) NOT NULL DEFAULT '',
`count_played` mediumint(9) NOT NULL DEFAULT '0',
`count_requested` mediumint(9) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
UNIQUE KEY `filename` (`filename`),
KEY `date_played` (`date_played`),
KEY `date_artist_played` (`date_artist_played`),
KEY `date_album_played` (`date_album_played`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=347 ;
Now basically on every song i can show the data making the call to history list. but i need to use the historylist id its pulling. to then connect to the artistlist id so it pulls the lyrics field
hope that helps more
Seems like your join condition is incorrect.
ON historylist.ID = artistlist.ID
If this to be work both table have to have 1-1 relationship. Looking at your table structure i think correct condition would be
ON historylist.artist = artistlist.artist

trouble with import query to database

I have this query and I tried to import it to phpmyadmin. Can you tell me how to fix this? Thank you.
DROP TABLE IF EXISTS `dp_confirms`;
CREATE TABLE `dp_confirms` (
`id` int(11) NOT NULL auto_increment,
`newuser` varchar(32) NOT NULL default '',
`newpass` varchar(32) NOT NULL default '',
`newquestion` varchar(255) NOT NULL default '',
`newanswer` varchar(255) NOT NULL default '',
`newmail` varchar(255) NOT NULL default '',
`newfname` varchar(32) NOT NULL default '',
`newlname` varchar(32) NOT NULL default '',
`newcompany` varchar(128) NOT NULL default '',
`newregnum` varchar(32) NOT NULL default '',
`newdrvnum` varchar(32) NOT NULL default '',
`newaddress` varchar(128) NOT NULL default '',
`newcity` varchar(64) NOT NULL default '',
`newcountry` char(2) NOT NULL default '',
`newstate` varchar(32) NOT NULL default '',
`newzip` varchar(32) NOT NULL default '',
`newphone` varchar(64) NOT NULL default '',
`newfax` varchar(64) NOT NULL default '',
`sponsor` int(11) NOT NULL default '0',
`confirm` varchar(255) NOT NULL default '',
`cdate` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `newuser` (`newuser`),
KEY `newmail` (`newmail`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
Error I get:
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 '(14) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `newuser` (`newuser`),
K' at line 22
Specifying the length for a timestamp such as timestamp(14) was deprecated in MySQL 5.1, and is no longer supported from MySQL 5.5.
This is easily fixed by removing the length specification:
`cdate` timestamp NOT NULL,

Using slash in MySQL database

I am using mysql with php Yii framework.When doing data modelling I came accross some doubt.I have a table for user details like this.
CREATE TABLE IF NOT EXISTS `tbl_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(80) NOT NULL DEFAULT '',
`lastname` varchar(80) NOT NULL DEFAULT '',
`gender` varchar(6) NOT NULL DEFAULT '',
`email` varchar(45) NOT NULL DEFAULT '',
`company_name` varchar(80) NOT NULL DEFAULT '',
`contact_no` varchar(45) NOT NULL DEFAULT '',
`address` varchar(120) NOT NULL DEFAULT '',
`state` varchar(45) NOT NULL DEFAULT '',
`country` varchar(45) NOT NULL DEFAULT '',
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=98 ;
Here my problem is I want the state,country should be like this so that I can use the fields like state/city
`state/city` varchar(45) NOT NULL DEFAULT '',
`state/province` varchar(45) NOT NULL DEFAULT '',
So is it safe to use like this or I have to use only one option there?Any help and suggestions will be highly appriciable.
Yes, it's valid. But you will always need to quote it with backticks.
See http://dev.mysql.com/doc/refman/5.5/en/identifiers.html for full details on what's allowed.

MySQL foreign key to another foreign key

The idea is quite simple: i have three (or more) tables
- master_tbl (id, something, somethingelse)
- tbl2 (id, ....)
- tbl3 (id, ....)
Now what i want is a foreign key relationship, such as tbl3.id would point to tbl2.id and tbl2.id would point to master_tbl.id - all foreign keys are ON UPDATE CASCADE and ON DELETE CASCADE. What I'll get from this is that when I delete a record from tbl2, its tbl3 equivalent will get erased as well, but not master_tbl. When I delete a record from master_tbl, all three tables get erased.
When I try to create the foreign key on tbl3.id->tbl2.id, I get mysql error 150 - can't create table (the tbl2.id->master_tbl.id is already created).
My MySQL version is 5.1.46. Any ideas why this might be?
EDIT: table definitions
smf_members aka master_table
-- Table "smf_members" DDL
CREATE TABLE `smf_members` (
`id_member` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`member_name` varchar(80) NOT NULL DEFAULT '',
`date_registered` int(10) unsigned NOT NULL DEFAULT '0',
`posts` mediumint(8) unsigned NOT NULL DEFAULT '0',
`id_group` smallint(5) unsigned NOT NULL DEFAULT '0',
`lngfile` varchar(255) NOT NULL DEFAULT '',
`last_login` int(10) unsigned NOT NULL DEFAULT '0',
`real_name` varchar(255) NOT NULL DEFAULT '',
`instant_messages` smallint(5) NOT NULL DEFAULT '0',
`unread_messages` smallint(5) NOT NULL DEFAULT '0',
`new_pm` tinyint(3) unsigned NOT NULL DEFAULT '0',
`buddy_list` text NOT NULL,
`pm_ignore_list` varchar(255) NOT NULL DEFAULT '',
`pm_prefs` mediumint(8) NOT NULL DEFAULT '0',
`mod_prefs` varchar(20) NOT NULL DEFAULT '',
`message_labels` text NOT NULL,
`passwd` varchar(64) NOT NULL DEFAULT '',
`openid_uri` text NOT NULL,
`email_address` varchar(255) NOT NULL DEFAULT '',
`personal_text` varchar(255) NOT NULL DEFAULT '',
`gender` tinyint(4) unsigned NOT NULL DEFAULT '0',
`birthdate` date NOT NULL DEFAULT '0001-01-01',
`website_title` varchar(255) NOT NULL DEFAULT '',
`website_url` varchar(255) NOT NULL DEFAULT '',
`location` varchar(255) NOT NULL DEFAULT '',
`icq` varchar(255) NOT NULL DEFAULT '',
`aim` varchar(255) NOT NULL DEFAULT '',
`yim` varchar(32) NOT NULL DEFAULT '',
`msn` varchar(255) NOT NULL DEFAULT '',
`hide_email` tinyint(4) NOT NULL DEFAULT '0',
`show_online` tinyint(4) NOT NULL DEFAULT '1',
`time_format` varchar(80) NOT NULL DEFAULT '',
`signature` text NOT NULL,
`time_offset` float NOT NULL DEFAULT '0',
`avatar` varchar(255) NOT NULL DEFAULT '',
`pm_email_notify` tinyint(4) NOT NULL DEFAULT '0',
`karma_bad` smallint(5) unsigned NOT NULL DEFAULT '0',
`karma_good` smallint(5) unsigned NOT NULL DEFAULT '0',
`usertitle` varchar(255) NOT NULL DEFAULT '',
`notify_announcements` tinyint(4) NOT NULL DEFAULT '1',
`notify_regularity` tinyint(4) NOT NULL DEFAULT '1',
`notify_send_body` tinyint(4) NOT NULL DEFAULT '0',
`notify_types` tinyint(4) NOT NULL DEFAULT '2',
`member_ip` varchar(255) NOT NULL DEFAULT '',
`member_ip2` varchar(255) NOT NULL DEFAULT '',
`secret_question` varchar(255) NOT NULL DEFAULT '',
`secret_answer` varchar(64) NOT NULL DEFAULT '',
`id_theme` tinyint(4) unsigned NOT NULL DEFAULT '0',
`is_activated` tinyint(3) unsigned NOT NULL DEFAULT '1',
`validation_code` varchar(10) NOT NULL DEFAULT '',
`id_msg_last_visit` int(10) unsigned NOT NULL DEFAULT '0',
`additional_groups` varchar(255) NOT NULL DEFAULT '',
`smiley_set` varchar(48) NOT NULL DEFAULT '',
`id_post_group` smallint(5) unsigned NOT NULL DEFAULT '0',
`total_time_logged_in` int(10) unsigned NOT NULL DEFAULT '0',
`password_salt` varchar(255) NOT NULL DEFAULT '',
`ignore_boards` text NOT NULL,
`warning` tinyint(4) NOT NULL DEFAULT '0',
`passwd_flood` varchar(12) NOT NULL DEFAULT '',
`pm_receive_from` tinyint(4) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id_member`),
KEY `member_name` (`member_name`),
KEY `real_name` (`real_name`),
KEY `date_registered` (`date_registered`),
KEY `id_group` (`id_group`),
KEY `birthdate` (`birthdate`),
KEY `posts` (`posts`),
KEY `last_login` (`last_login`),
KEY `lngfile` (`lngfile`(30)),
KEY `id_post_group` (`id_post_group`),
KEY `warning` (`warning`),
KEY `total_time_logged_in` (`total_time_logged_in`),
KEY `id_theme` (`id_theme`)
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8;
cyp_users aka tbl2
-- Table "cyp_users" DDL
CREATE TABLE `cyp_users` (
`id` mediumint(8) unsigned NOT NULL,
`role` varchar(255) NOT NULL DEFAULT 'unregistered',
PRIMARY KEY (`id`),
CONSTRAINT `cyp_users_ibfk_1` FOREIGN KEY (`id`) REFERENCES `smf_members` (`id_member`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
cyp_vip_users aka tbl3
-- Table "cyp_vip_users" DDL
CREATE TABLE `cyp_vip_users` (
`id` mediumint(8) NOT NULL,
`od` date NOT NULL,
`do` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The ID's of tbl2 and tbl3 are different types.
Foreign Keys need to be of the same type.
tbl2.ID is UNSIGNED
tbl3.ID is SIGNED

mysql query times out after certain periodof inactivity - query cache issue i think

using latest mysql server,
after some period of inactivity my website sqls times out (only some not all)
these queries are not newly written existing queries.
Testing results
when execute a simple sql like (select count(*) from products) this works fine all the time.
when execute below sql
SELECT products.pid
FROM
products INNER JOIN
catalog ON products.cid=catalog.cid
WHERE
products.is_visible = 'Yes' AND (
products.inventory_control = 'No' OR
products.stock > 0 OR
products.inventory_rule = 'OutOfStock' OR (
products.inventory_control = 'AttrRuleInc' AND
products.stock >= 0
)
) AND products.is_home = 'Yes'
GROUP BY products.pid
it times out ( Note it will not timeout all the time, this happens after 1 hour or 2 hour of inactivity)
The very first execution takes 30+ seconds and it times out and after that the above executing SQL 2 to 3 times the 4th time onwards it executes fast in 3 to 5 seconds
after 1 or 2 hour inactivity this pattern repeats.
I did not do any changes in settings.
i have 2 sites on this server.
1st server has 20,000 rows of in database ( this one works fine ) 2nd site has 150,000 rows in the databse ( this one is having this issue)
So this is something "query time out"
i do not think this is something on SQL settings, if it is then i should see this behavior on both sites
**** here is the table structure for which the issue with timeout / taking 40 seconds
#this structure has 2 additional keys we created
# KEY `product_id` (`product_id`),
# KEY `product_no` (`product_no`)
# this one is having issues
--
-- Table structure for table `products` on lpbatt database server
--
DROP TABLE IF EXISTS `products`;
SET #saved_cs_client = ##character_set_client;
SET character_set_client = utf8;
CREATE TABLE `products` (
`pid` int(10) unsigned NOT NULL auto_increment,
`cid` int(10) unsigned NOT NULL default '0',
`manufacturer_id` int(10) unsigned NOT NULL default '0',
`is_visible` enum('Yes','No') NOT NULL default 'Yes',
`is_hotdeal` enum('Yes','No') NOT NULL default 'No',
`is_home` enum('Yes','No') NOT NULL default 'No',
`is_taxable` enum('Yes','No') NOT NULL default 'Yes',
`is_dollar_days` enum('Yes','No') NOT NULL default 'No',
`is_google_co` enum('Yes','No') NOT NULL default 'Yes',
`is_doba` enum('Yes','No') NOT NULL default 'No',
`is_locked` enum('Yes','No') NOT NULL default 'No',
`inventory_control` enum('Yes','AttrRuleExc','AttrRuleInc','No') NOT NULL default 'No',
`inventory_rule` enum('Hide','OutOfStock') NOT NULL default 'Hide',
`stock` int(10) NOT NULL default '0',
`stock_warning` int(10) NOT NULL default '0',
`weight` decimal(10,2) unsigned NOT NULL default '0.00',
`free_shipping` enum('Yes','No') NOT NULL default 'No',
`digital_product` enum('Yes','No') NOT NULL default 'No',
`digital_product_file` varchar(255) NOT NULL default '',
`cost` decimal(20,5) unsigned NOT NULL default '0.00000',
`price` decimal(20,5) unsigned NOT NULL default '0.00000',
`price2` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_1` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_2` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_3` decimal(20,5) unsigned NOT NULL default '0.00000',
`shipping_price` decimal(20,5) unsigned NOT NULL default '0.00000',
`tax_class_id` int(10) unsigned NOT NULL default '0',
`tax_rate` decimal(20,5) NOT NULL default '-1.00000',
`call_for_price` enum('Yes','No') NOT NULL default 'No',
`priority` int(11) NOT NULL default '0',
`attributes_count` int(11) NOT NULL default '0',
`min_order` int(10) NOT NULL default '1',
`max_order` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`products_location_id` int(10) unsigned NOT NULL default '0',
`url_hash` varchar(32) NOT NULL default '',
`url_default` varchar(128) NOT NULL default '',
`url_custom` varchar(128) NOT NULL default '',
`product_id` int(64) NOT NULL default '0',
`product_sku` varchar(64) NOT NULL default '',
`product_upc` varchar(64) NOT NULL default '',
`case_pack` int(11) NOT NULL default '-1',
`inter_pack` int(11) NOT NULL default '-1',
`gift_quantity` int(10) unsigned NOT NULL default '0',
`dimension_width` decimal(10,2) NOT NULL default '0.00',
`dimension_length` decimal(10,2) NOT NULL default '0.00',
`dimension_height` decimal(10,2) NOT NULL default '0.00',
`image_location` enum('Local','Web') NOT NULL default 'Local',
`image_url` varchar(255) NOT NULL default '',
`image_alt_text` varchar(255) NOT NULL default '',
`tmp_manufacturer` varchar(30) default NULL,
`tmp_family` varchar(30) default NULL,
`tmp_series` varchar(30) default NULL,
`tmp_model` varchar(30) default NULL,
`tmp_ptype` varchar(30) default NULL,
`product_no` varchar(40) default NULL,
`part_no` varchar(300) default NULL,
`spec_1` varchar(7) default NULL,
`spec_2` varchar(7) default NULL,
`spec_3` varchar(7) default NULL,
`spec_4` varchar(40) default NULL,
`title` varchar(255) NOT NULL default '',
`meta_keywords` text NOT NULL,
`meta_title` text NOT NULL,
`meta_description` text NOT NULL,
`overview` text,
`description` text,
`zoom_option` enum('global','none','zoom','magnify','magicthumb','imagelayover') NOT NULL default 'global',
PRIMARY KEY (`pid`),
KEY `cid` (`cid`),
KEY `is_visible` (`is_visible`),
KEY `url_hash` (`url_hash`),
KEY `product_id` (`product_id`),
KEY `product_no` (`product_no`)
) ENGINE=MyISAM AUTO_INCREMENT=1630746530 DEFAULT CHARSET=utf8;
SET character_set_client = #saved_cs_client;
below is the table structure which is running on another server but working fine
#see the products table structure and catalog table structure
#this is fine on this server
# --------------------------------------------------------
# Host: laptopnbparts.com
# Database: laptopnbpartscom
# Server version: 5.0.77
# Server OS: redhat-linux-gnu
# HeidiSQL version: 5.0.0.3222
# Date/time: 2010-06-25 18:13:33
# --------------------------------------------------------
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
# Dumping structure for table laptopnbpartscom.catalog
CREATE TABLE IF NOT EXISTS `catalog` (
`cid` int(10) unsigned NOT NULL auto_increment,
`parent` int(10) unsigned NOT NULL default '0',
`level` int(10) unsigned NOT NULL default '0',
`priority` smallint(5) unsigned NOT NULL default '5',
`is_visible` enum('Yes','No') NOT NULL default 'Yes',
`list_subcats` enum('Yes','No') NOT NULL default 'No',
`url_hash` varchar(32) NOT NULL default '',
`url_default` varchar(128) NOT NULL default '',
`url_custom` varchar(128) NOT NULL default '',
`key_name` varchar(255) NOT NULL default '',
`meta_keywords` text,
`meta_title` text,
`meta_description` text,
`category_header` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`description` text,
`description_bottom` text,
`category_path` text,
PRIMARY KEY (`cid`),
KEY `parent` (`parent`),
KEY `level` (`level`),
KEY `priority` (`priority`),
KEY `url_hash` (`url_hash`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
# Data exporting was unselected.
# Dumping structure for table laptopnbpartscom.products
CREATE TABLE IF NOT EXISTS `products` (
`pid` int(10) unsigned NOT NULL auto_increment,
`cid` int(10) unsigned NOT NULL default '0',
`manufacturer_id` int(10) unsigned NOT NULL default '0',
`is_visible` enum('Yes','No') NOT NULL default 'Yes',
`is_hotdeal` enum('Yes','No') NOT NULL default 'No',
`is_home` enum('Yes','No') NOT NULL default 'No',
`is_taxable` enum('Yes','No') NOT NULL default 'Yes',
`is_dollar_days` enum('Yes','No') NOT NULL default 'No',
`is_google_co` enum('Yes','No') NOT NULL default 'Yes',
`is_doba` enum('Yes','No') NOT NULL default 'No',
`is_locked` enum('Yes','No') NOT NULL default 'No',
`inventory_control` enum('Yes','AttrRuleExc','AttrRuleInc','No') NOT NULL default 'No',
`inventory_rule` enum('Hide','OutOfStock') NOT NULL default 'Hide',
`stock` int(10) NOT NULL default '0',
`stock_warning` int(10) NOT NULL default '0',
`weight` decimal(10,2) unsigned NOT NULL default '0.00',
`free_shipping` enum('Yes','No') NOT NULL default 'No',
`digital_product` enum('Yes','No') NOT NULL default 'No',
`digital_product_file` varchar(255) NOT NULL default '',
`cost` decimal(20,5) unsigned NOT NULL default '0.00000',
`price` decimal(20,5) unsigned NOT NULL default '0.00000',
`price2` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_1` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_2` decimal(20,5) unsigned NOT NULL default '0.00000',
`price_level_3` decimal(20,5) unsigned NOT NULL default '0.00000',
`shipping_price` decimal(20,5) unsigned NOT NULL default '0.00000',
`tax_class_id` int(10) unsigned NOT NULL default '0',
`tax_rate` decimal(20,5) NOT NULL default '-1.00000',
`call_for_price` enum('Yes','No') NOT NULL default 'No',
`priority` int(11) NOT NULL default '0',
`attributes_count` int(11) NOT NULL default '0',
`min_order` int(10) NOT NULL default '1',
`max_order` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`products_location_id` int(10) unsigned NOT NULL default '0',
`url_hash` varchar(32) NOT NULL default '',
`url_default` varchar(128) NOT NULL default '',
`url_custom` varchar(128) NOT NULL default '',
`product_id` varchar(64) NOT NULL default '',
`product_sku` varchar(64) NOT NULL default '',
`product_upc` varchar(64) NOT NULL default '',
`case_pack` int(11) NOT NULL default '-1',
`inter_pack` int(11) NOT NULL default '-1',
`gift_quantity` int(10) unsigned NOT NULL default '0',
`dimension_width` decimal(10,2) NOT NULL default '0.00',
`dimension_length` decimal(10,2) NOT NULL default '0.00',
`dimension_height` decimal(10,2) NOT NULL default '0.00',
`image_location` enum('Local','Web') NOT NULL default 'Local',
`image_url` varchar(255) NOT NULL default '',
`image_alt_text` varchar(255) NOT NULL default '',
`tmp_manufacturer` varchar(30) default NULL,
`tmp_series` varchar(30) default NULL,
`tmp_model` varchar(30) default NULL,
`tmp_ptype` varchar(30) default NULL,
`product_no` varchar(60) default NULL,
`part_no` varchar(60) default NULL,
`watt_volt_amp` varchar(100) default NULL,
`title` varchar(255) NOT NULL default '',
`meta_keywords` text NOT NULL,
`meta_title` text NOT NULL,
`meta_description` text NOT NULL,
`overview` text,
`description` text,
`zoom_option` enum('global','none','zoom','magnify','magicthumb','imagelayover') NOT NULL default 'global',
PRIMARY KEY (`pid`),
KEY `cid` (`cid`),
KEY `is_visible` (`is_visible`),
KEY `url_hash` (`url_hash`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
# Data exporting was unselected.
/*!40101 SET SQL_MODE=#OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
Try using CASE WHEN instead of the multiple OR statements in the WHERE clause and evaluate on the client side.
OR is a well-known performance killer as MySQL cannot usually apply INDEXes and must check every single statement in order to filter out rows.