我想在更详细的搜索按钮点击上使用程序,其中如果我输入所有输入值则显示适当的结果。但是,我想让我的程序更加动态,如果我没有输入任何Game_Platform,那么它将显示基于其他过滤器的所有记录,包括game_plaform的等效值。此外,如果缺少平台或完整性或任何其他值,那么它也应返回所有可能过滤器的查询结果。那么,我如何处理Enum Column的以下错误?
Procdeure电话: 调用sp_search_Records_on_all_conditions_With_Blank(' asdasd','极限运动'' 3','''',& #39; Good',' 2000-11-07',#39; 2011-06-15',12,67)
错误代码: 1265.数据截断列' Platform_Name_ip'在第1行0.000秒
另外,我想知道如何从日期到日期,从价格到价格应用此类过滤器?
以下是我的程序,有人可以帮我找错吗?
USE `videogame_collection_1`;
DROP procedure IF EXISTS `sp_search_Records_on_all_conditions_With_Blank`;
DELIMITER $$
USE `videogame_collection_1`$$
CREATE PROCEDURE `sp_search_Records_on_all_conditions_With_Blank` (IN Game_Name_ip VARCHAR(100),IN Genre_ip ENUM('Controllers', 'Extreme Sports', 'Action & Adventure', 'Racing', 'RPG', 'Baseball', 'Sports', 'Systems', 'Puzzle', 'Fighting', 'Strategy', 'FPS', 'Wrestling', 'Accessories', 'Soccer', 'Other', 'Football', 'Party', 'Arcade', 'Basketball', 'Simulation', 'Music'),
IN Rating_ip ENUM('1', '2', '3', '4', '5'),IN Platform_Name_ip ENUM('N64', 'NES', 'Super Nintendo', 'Gamecube', 'Wii', 'Playstation 1', 'Playstation 2', 'Playstation 3', 'Xbox', 'Xbox 360', 'Sega Genesis', 'Atari 2600', 'Gameboy Color', 'Gameboy Advance'),IN Completeness_Type_ip ENUM('B', 'I', 'C', 'BC', 'BI', 'IC', 'BIC'), IN Condition_ip ENUM('New', 'Mint', 'Very Good', 'Good', 'Acceptable', 'Poor'),
IN from_Purchase_date_ip DATE,IN to_Purchase_date_ip DATE ,IN from_Purchase_Price_ip DECIMAL(4,2), IN to_Purchase_Price_ip DECIMAL(4,2))
Begin
SET sql_mode = '';
SELECT
video_game.Game_Name,
video_game.Genre,
video_game.Rating,
platform.Platform_Name,
mycollection.Completeness_Type,
mycollection.`Condition`,
mycollection.Purchase_Date,
mycollection.Purchase_Price
FROM
video_game
INNER JOIN
video_game_platform_mycollection ON video_game.Game_Id = video_game_platform_mycollection.Game_Id
INNER JOIN
platform ON video_game_platform_mycollection.Platform_Id = platform.Platform_Id
INNER JOIN
mycollection ON video_game_platform_mycollection.MyCollection_Id = mycollection.MyCollection_Id
where (Game_Name_ip is null OR len(trim(Game_Name_ip)) > 0) or video_game.Game_Name LIKE CONCAT('%', Game_Name_ip, '%') and (Genre_ip is null OR len(trim(Genre_ip)) > 0) or video_game.Genre=Genre_ip and (Rating_ip is null OR len(trim(Rating_ip)) > 0) or video_game.Rating=Rating_ip
and (Platform_Name_ip is null OR len(trim(Platform_Name_ip)) > 0) or platform.Platform_Name=Platform_Name_ip and (Completeness_Type_ip is null OR len(trim(Completeness_Type_ip)) > 0) or mycollection.Completeness_Type=Completeness_Type_ip and (Condition_ip is null OR len(trim(Condition_ip)) > 0) or mycollection.`Condition`= Condition_ip
and mycollection.Purchase_Date between from_Purchase_date_ip and to_Purchase_date_ip and mycollection.Purchase_Price >=from_Purchase_Price_ip and mycollection.Purchase_Price<= to_Purchase_Price_ip;
END
$$
DELIMITER ;