CREATE TABLE `schedule` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `aircraftType` varchar(50) DEFAULT NULL,
//...other fields
  PRIMARY KEY (`id`),
) ENGINE=MyISAM AUTO_INCREMENT=5611 DEFAULT CHARSET=latin1;

CREATE TABLE `aircrafts` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `aircraftType` varchar(50) DEFAULT NULL,
//...other fields
  PRIMARY KEY (`id`),
) ENGINE=MyISAM AUTO_INCREMENT=5611 DEFAULT CHARSET=latin1;

数据库表的示例内容:
表“附表”
aircraftType = "320"

表“飞机”
aircraftType = "A320"
aircraftType = "A330"

查询:
SELECT *
FROM Schedule F, Aircrafts A
WHERE F.aircraftType = A.aircraftType;

如何更新此查询,以便在WHERE子句中将空勤人员类型“320”和“A320”视为相似?

最佳答案

 SELECT *
FROM Schedule F, Aircrafts A
WHERE F.aircraftType = A.aircraftType LIKE CONCAT('%', F.aircraftType, '%')

或者
LIKE CONCAT('\"','%', F.aircraftType, '%','\"')-added double quotes.

关于mysql - 如何更新WHERE子句以选择相同的数据?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18512898/

10-12 02:48