LIKE 运算符无法正常工作

LIKE operator isn't working properly

我正在尝试更新数据库中的一些值,我获取要更新的值的主要 table 具有以下结构:

http://api.football-data.org/alpha/soccerseasons/403/leagueTable 所以在更新查询中我执行这个语句:

UPDATE leaguetable SET matchDay = ?, position = ?, teamName = ?, 
playedGames = ?, points = ?, goals = ?, goalsAgainst = ?, 
goalDifference = ?, self = ?, soccerSeason = ?, team = ? WHERE
self LIKE 'http://api.football-data.org/alpha/soccerseasons/403/leagueTable'"

这个查询是正确的,但是当我在 PhpMyAdmin 的控制台中尝试它时它 returns 0 rows 因为值 self 有这个结构:

http://api.football-data.org/alpha/soccerseasons/403/leagueTable/?matchday=2

like 属性我做错了什么?

注意:我在名为$x的变量中传递值http://api.football-data.org/alpha/soccerseasons/403/leagueTable,在post中link是只是显示 link.

布局的示例

尝试在它后面加上 %(通配符):

UPDATE leaguetable SET matchDay = ?, position = ?, teamName = ?, 
        playedGames = ?, points = ?, goals = ?, goalsAgainst = ?, 
        goalDifference = ?, self = ?, soccerSeason = ?, team = ?    WHERE self     LIKE 'http://api.football-data.org/alpha/soccerseasons/403/leagueTable%'

您必须使用通配符才能获得输出

UPDATE leaguetable SET matchDay = ?, position = ?, teamName = ?, 
playedGames = ?, points = ?, goals = ?, goalsAgainst = ?, 
goalDifference = ?, self = ?, soccerSeason = ?, team = ?    WHERE self LIKE 'http://api.football-data.org/alpha/soccerseasons/403/leagueTable%'"

您需要包含通配符 % 才能正常工作。

在此处阅读更多相关信息 MSDN LIKE

具体关于通配符%

'http://api.football-data.org/alpha/soccerseasons/403/leagueTable%' 查找所有以给定开头的 URL,包括所需的 /?matchday=2.

在您的代码中:

UPDATE leaguetable 
SET matchDay = ?, position = ?, teamName = ?, playedGames = ?, points = ?, goals = ?, goalsAgainst = ?, goalDifference = ?, self = ?, soccerSeason = ?, team = ?    
WHERE self LIKE 'http://api.football-data.org/alpha/soccerseasons/403/leagueTable%'