Hi there, I need your appreciated help.
If execute this select query:
SELECT * FROM `tbl_A` WHERE 1 AND `On_Off` = '1';
I have this output:
Affected rows: 2.962
Time: 0.312ms
If execute this select query with Join:
SELECT * FROM tbl_A A
JOIN tbl_CA CA ON CA.User_Number = A.User_Number
WHERE 1
AND `On_Off` = '1';
I have this other output:
Affected rows: 3.336
Time: 0.250ms
Why this difference?
Which this 3336-2962 = 374 records?
I need transfers this 2.962 records in other table MySQL when the field User_Number
of table tbl_A
corresponding with the field User_Number
of table tbl_CA
, but if condition of tbl_A
On_Off
= ‘1’ is respected.
Can you help me?
Thanks in advance, cheers.
This is my tables in MySQL:
/*
Navicat MySQL Data Transfer
Source Server : _MySQL
Source Server Version : 50045
Source Host : localhost:3306
Source Database : db_
Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001
Date: 2011-08-18 11:02:32
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `tbl_A`
-- ----------------------------
DROP TABLE IF EXISTS `tbl_A`;
CREATE TABLE `tbl_A` (
`xID` int(11) NOT NULL auto_increment,
`User_Number` varchar(11) default NULL,
`On_Off` tinyint(4) default '0',
PRIMARY KEY (`xID`),
KEY `On_Off` (`On_Off`),
) ENGINE=MyISAM AUTO_INCREMENT=18637 DEFAULT CHARSET=latin1;
/*
Navicat MySQL Data Transfer
Source Server : _MySQL
Source Server Version : 50045
Source Host : localhost:3306
Source Database : db_
Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001
Date: 2011-08-18 11:02:45
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `tbl_CA`
-- ----------------------------
DROP TABLE IF EXISTS `tbl_CA`;
CREATE TABLE `tbl_CA` (
`ID` int(10) NOT NULL auto_increment,
`User_Number` varchar(255) default NULL,
PRIMARY KEY USING BTREE (`ID`),
KEY `User_Number` (`User_Number`),
) ENGINE=InnoDB AUTO_INCREMENT=24239 DEFAULT CHARSET=latin1;