There are some columns in my mysql table which contain values such as "Sbeed Pharmaceuticals åÊ" . Two questions:
How do I prevent getting these characters from getting into the table in the first place ?
How do I find rows containing these characters ?
Here is the table:
CREATE TABLE `drugs` (
`drug-id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`th-class` varchar(512) DEFAULT NULL,
`division` varchar(512) DEFAULT NULL,
`name` varchar(512) DEFAULT NULL,
`brand-name` varchar(64) DEFAULT NULL,
`pack` varchar(512) DEFAULT NULL,
`rx-type` varchar(16) DEFAULT NULL,
`pack-form` varchar(128) DEFAULT NULL,
`available-in` varchar(512) DEFAULT NULL,
`mrp` double DEFAULT '-1',
`mrp-per-unit` double DEFAULT NULL,
`manufacturer` varchar(512) DEFAULT NULL,
`schemes` text,
`drug-status` varchar(64) DEFAULT 'new',
`created-by` varchar(512) DEFAULT NULL,
`created-at` datetime DEFAULT CURRENT_TIMESTAMP,
`approved-at` datetime DEFAULT NULL,
`approved-by` varchar(512) DEFAULT NULL,
`dosage` varchar(64) DEFAULT NULL,
`manufacturer-id` int(10) DEFAULT NULL,
PRIMARY KEY (`drug-id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Related
I have an SQL file for a database from an old custom blog CMS. I am trying to import the articles into WordPress but I am now stuck. So far, I have managed to isolate the table structures for the CMS (see below). I have also identified the columns that i need. These are (Post, Title, Date, Image, Category). Now I have to map these columns to some columns in the Wordpress schema somehow and that is where I am getting stuck.
Here is the SQL structure of the database:
CREATE TABLE `ads_ng_ads` (
`id` int(10) unsigned NOT NULL auto_increment,
`ad_type` enum('media','text','html') character set latin1 collate latin1_bin NOT NULL,
`media_type` enum('image','flash','other') character set latin1 collate latin1_bin default NULL,
`media_width` smallint(6) default NULL,
`media_height` smallint(6) default NULL,
`media_size` int(6) default NULL,
`media_path` varchar(128) character set latin1 collate latin1_bin default NULL,
`uri` varchar(128) character set utf8 collate utf8_bin NOT NULL,
`is_hidden` tinyint(1) NOT NULL,
`created_on` int(11) NOT NULL,
`active_from` int(11) NOT NULL,
`active_to` int(11) NOT NULL,
`room_id` int(11) default NULL,
`geo_target` int(11) default NULL,
`alternative` text character set utf8 NOT NULL,
`zone_target` text character set ascii collate ascii_bin NOT NULL,
`uri_target` text character set utf8 collate utf8_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `zone_target` (`is_hidden`,`active_from`,`active_to`,`geo_target`)
) ENGINE=MyISAM AUTO_INCREMENT=757 DEFAULT CHARSET=latin1;
CREATE TABLE `ads_ng_statistics` (
`ad_id` int(10) unsigned NOT NULL,
`date` int(11) NOT NULL,
`views` mediumint(8) unsigned NOT NULL default '0',
`clicks` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`ad_id`,`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE `countries` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`alias` varchar(3) NOT NULL,
`restricted` tinyint(3) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=253 DEFAULT CHARSET=utf8;
CREATE TABLE `featured_column` (
`id` int(11) unsigned NOT NULL auto_increment,
`date_modified` timestamp NOT NULL default CURRENT_TIMESTAMP,
`date_created` timestamp NOT NULL default '1000-01-01 00:00:00',
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`body` text NOT NULL,
`body_html` text NOT NULL,
`user_id` int(11) NOT NULL,
`tags` varchar(255) NOT NULL,
`summary` varchar(255) NOT NULL,
`in_homepage` int(1) NOT NULL default '0',
`img_title` int(1) NOT NULL default '0',
`meta_t` varchar(255) NOT NULL,
`meta_k` varchar(255) NOT NULL,
`meta_d` varchar(255) NOT NULL,
`public` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1381 DEFAULT CHARSET=utf8;
Assuming that you're using the latest WordPress version(4.9.1), you just need to create a script that will import all data to table wp_posts for example if you want to import as WordPress posts. Example: "Title" to "post_title", "post" to "post_content", etc.
I have a database for contacts and Phpmyadmin is giving me weird ids. Sometimes Ids start from 67000 sth and sometimes from 7. In my operations-->auto_increment is set to 676503. I try to change it and press go. It does not change.It keeps on giving me the same number. Also, when I click to show the data, when Ids and contacts are displayed, a column named rows is displayed. The column has only the value 1 for all contacts, as if all contacts are in row 1.
How can I fix this?
Edit:
contacts
CREATE TABLE `contacts` (
`id` int(5) NOT NULL auto_increment,
`date_entered` datetime default NULL,
`date_modified` datetime default NULL,
`modified_user_id` char(36) default NULL,
`created_by` char(36) default NULL,
`description` text,
`deleted` tinyint(1) default '0',
`assigned_user_id` int(36) NOT NULL,
`salutation` varchar(255) default NULL,
`first_name` varchar(100) default NULL,
`last_name` varchar(100) default NULL,
`title` varchar(100) default NULL,
`department` varchar(255) default NULL,
`do_not_call` tinyint(1) default '0',
`phone_home` varchar(100) default NULL,
`phone_mobile` varchar(100) default NULL,
`phone_work` varchar(100) default NULL,
`phone_other` varchar(100) default NULL,
`phone_fax` varchar(100) default NULL,
`primary_address_street` varchar(150) default NULL,
`primary_address_city` varchar(100) default NULL,
`primary_address_state` varchar(100) default NULL,
`primary_address_postalcode` varchar(20) default NULL,
`primary_address_country` varchar(255) default NULL,
`alt_address_street` varchar(150) default NULL,
`alt_address_city` varchar(100) default NULL,
`alt_address_state` varchar(100) default NULL,
`alt_address_postalcode` varchar(20) default NULL,
`alt_address_country` varchar(255) default NULL,
`assistant` varchar(75) default NULL,
`assistant_phone` varchar(100) default NULL,
`lead_source` varchar(255) default NULL,
`reports_to_id` char(36) default NULL,
`birthdate` date default NULL,
`campaign_id` char(36) default NULL,
`age` datetime default NULL,
`days_old` int(6) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `id_2` (`id`),
UNIQUE KEY `id_3` (`id`),
UNIQUE KEY `id_4` (`id`),
UNIQUE KEY `id_5` (`id`),
UNIQUE KEY `id_6` (`id`),
UNIQUE KEY `id_7` (`id`),
KEY `idx_cont_last_first` (`last_name`,`first_name`,`deleted`),
KEY `idx_contacts_del_last` (`deleted`,`last_name`),
KEY `idx_cont_del_reports` (`deleted`,`reports_to_id`,`last_name`),
KEY `idx_reports_to_id` (`reports_to_id`),
KEY `idx_del_id_user` (`deleted`,`id`,`assigned_user_id`),
KEY `idx_cont_assigned` (`assigned_user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=676504 DEFAULT CHARSET=utf8
I am getting following error please help me whats the reason
Duplicate entry '2014-02-28' for key 1
CREATE TABLE `th_userinfo` (
`user_id` varchar(250) NOT NULL,
`firstname` varchar(100) default NULL,
`lastname` varchar(100) default NULL,
`fb_id` varchar(250) default NULL,
`email` varchar(255) default NULL,
`gender` varchar(255) default NULL,
`age` varchar(20) default NULL,
`city` varchar(50) default NULL,
`prefix` varchar(10) default NULL,
`mobile` varchar(15) default NULL,
`created` datetime default NULL,
`status` varchar(100) default NULL,
`utm_source` varchar(100) default NULL,
`utm_content` varchar(200) default NULL,
`utm_medium` varchar(100) default NULL,
`utm_campaign` varchar(100) default NULL,
`app_type` varchar(50) default NULL,
`access_token` varchar(250) default NULL,
`modified_access_token` varchar(255) default NULL,
`user_browser` varchar(250) default NULL,
`is_token_expire` varchar(250) default 'No',
`education` varchar(350) default NULL,
`work` text,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
QUERY
UPDATE th_userinfo
SET prefix='0311', mobile='1111111', STATUS='B'
WHERE user_id='1615972863'
You probably have a trigger on that table which inserts/updates values in some other table. This is probably what causes the issue and not the original update on the current th_userinfo table.
I have a table that was inherited from a different system and one of the fields has the UUID function enabled so no matter what ID I generate and try to insert, the table creates a completely different one automatically.
I would like to use a PHP function to create the ID instead but I can't workout how to remove the UUID function from the field.
I am not sure what information will be needed to help you so please feel free to ask.
The field in question is
id, char(36)
Table definaition is..
CREATE TABLE `users` (
`id` char(36) NOT NULL,
`user_name` varchar(60) default NULL,
`user_hash` varchar(32) default NULL,
`diary_weekly_view` varchar(500) NOT NULL,
`week_start` date NOT NULL,
`diary_monthly_view` varchar(300) NOT NULL,
`diary_view` int(1) NOT NULL default '1',
`account_search` varchar(1000) NOT NULL,
`cases_search` varchar(500) NOT NULL,
`serials_search` varchar(500) NOT NULL,
`type` varchar(8) NOT NULL,
`email` varchar(255) NOT NULL,
`notes` varchar(3000) NOT NULL,
`authenticate_id` varchar(100) default NULL,
`sugar_login` tinyint(1) default '1',
`first_name` varchar(30) default NULL,
`last_name` varchar(30) default NULL,
`reports_to_id` char(36) default NULL,
`is_admin` tinyint(1) default '0',
`receive_notifications` tinyint(1) default '1',
`date_entered` datetime NOT NULL,
`date_modified` datetime NOT NULL,
`modified_user_id` char(36) default NULL,
`created_by` char(36) default NULL,
`phone_office` varchar(50) default NULL,
`phone_mobile` varchar(50) default NULL,
`status` varchar(25) default NULL,
`address_street` varchar(150) default NULL,
`address_city` varchar(100) default NULL,
`address_state` varchar(100) default NULL,
`address_country` varchar(25) default NULL,
`address_postalcode` varchar(9) default NULL,
`user_preferences` text,
`deleted` tinyint(1) NOT NULL default '0',
`portal_only` tinyint(1) default '0',
`employee_status` varchar(25) default NULL,
`is_group` tinyint(1) default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf
OK, sussed it, I removed the index and then recreated the index with INDEX
When I am trying to rum query I find error like
#1267 - Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
My table structure are
CREATE TABLE `empregistration` (
`id` int(100) NOT NULL auto_increment,
`cname` text NOT NULL,
`cpersonname` text NOT NULL,
`roaddress` text NOT NULL,
`txtcity` text NOT NULL,
`txtstate` text NOT NULL,
`txtcountry` text NOT NULL,
`faxno` varchar(255) NOT NULL,
`contactno` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL,
`empCat` varchar(255) NOT NULL,
`empno` varchar(255) NOT NULL,
`ctype` varchar(255) NOT NULL,
`establishyear` varchar(255) NOT NULL,
`txtjobcategory` text NOT NULL,
`cemailid` varchar(255) NOT NULL,
`calteremailid` varchar(255) NOT NULL,
`aboutcompany` text NOT NULL,
`password` varchar(255) NOT NULL,
`conpassword` varchar(255) NOT NULL,
`empLogo` varchar(255) NOT NULL,
`paymenttype` varchar(255) NOT NULL,
`regDate` int(11) default NULL,
`countViewProf` varchar(200) default '0',
`cntDownProf` varchar(200) default '0',
`cntJobPost` varchar(200) default '0',
`cntupdatejob` varchar(200) NOT NULL default '0',
`limitjobpost` varchar(200) NOT NULL default '0',
`limitofupdatejob` varchar(200) NOT NULL default '0',
`limitofviewcv` varchar(200) NOT NULL default '0',
`limitofdowncv` varchar(200) NOT NULL default '0',
`paymentforpostjob` varchar(200) NOT NULL default '0',
`paymentforsearchcv` varchar(200) NOT NULL default '0',
`takenPlan` varchar(255) default '0',
`planDate` date default NULL,
`takenplanforpostjob` varchar(200) NOT NULL default '0',
`postjobplandate` varchar(200) NOT NULL default '0',
`cntJobPost1` varchar(200) default '0',
`cntupdatejob1` varchar(200) default '0',
`status` varchar(255) NOT NULL default 'Active',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=214 ;
and other table is
CREATE TABLE `blockedcompanies` (
`blockedId` int(11) NOT NULL auto_increment,
`empId` varchar(50) collate latin1_general_ci NOT NULL,
`regId` int(11) NOT NULL,
`jobSeekId` varchar(50) collate latin1_general_ci NOT NULL,
`blockDate` date NOT NULL,
PRIMARY KEY (`blockedId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=5 ;
You don't show your query, but i expect you're doing a where somehow with an '=' in there. Now your default collation seems to be swedish, and your 'blockedcompanies' table has a collation to latin1_general.
The error says "implicit", so you're not doing something with collation in your query. Now you have to different collation being compared. You've got to change that using COLLATE
check this: http://dev.mysql.com/doc/refman/5.0/en/charset-collate.html
when you create the table empregistration, change the final line from
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=214 ;
to
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=214 ;
and your query should start working.