0

I have the following SQL query and want the replace all occurrences of the phrase "Vitality Blast" in the League field with "Twenty20 Cup (England)". To do this I think I need to use the Replace function but I do not know how to integrate it.

Can anyone point me in the right direction?

Thanks

SELECT BallByBall.matchId, BallByBall.inningsNo, BallByBall.ballNumber, BallByBall.ballRank, BallByBall.bowler, BallByBall.batsman, BallByBall.runs, BallByBall.byes, BallByBall.legByes, BallByBall.wides, BallByBall.noBalls, BallByBall.wicket, Lineups.bowlingStyle, Matches.League, Matches.convDate, ScorecardBatting.howDismissed, (SELECT COUNT(T2.ballRank) + 1
FROM BallByBall T2
WHERE T2.matchId = BallByBall.matchId
AND T2.batsman = BallByBall.batsman
AND T2.ballRank < BallByBall.ballRank
) AS Rank
FROM ScorecardBatting RIGHT JOIN (Matches RIGHT JOIN (Lineups RIGHT JOIN BallByBall ON (Lineups.matchId = BallByBall.matchId) AND (Lineups.playerId = BallByBall.bowler)) ON Matches.matchId = BallByBall.matchId) ON (ScorecardBatting.matchId = BallByBall.matchId) AND (ScorecardBatting.batsmanId = BallByBall.batsman)
ORDER BY BallByBall.matchId, BallByBall.inningsNo, BallByBall.ballRank;
8
  • Do you want to update that field or to display replacement? Commented Sep 10, 2020 at 12:25
  • Hi Maciej, I'd like to update that field. Thanks Commented Sep 10, 2020 at 12:43
  • What's your input data? Commented Sep 10, 2020 at 12:51
  • Hi Maciej, it's text from a csv file. Is that what you mean? Commented Sep 10, 2020 at 13:05
  • Yeah. And i'm also interested what you mean by saying: "replace all occurrences of the phrase "Vitality Blast" in the League field with "Twenty20 Cup (England)"". Does "Visibilit Blast" exists in League field more then once per row? Commented Sep 10, 2020 at 13:15

1 Answer 1

1

In reference to our discussion in comments, you have to use UPDATE statement.

UPDATE YourTableName SET League = 'Twenty20 Cup (England)'
WHERE League = 'Vitality Blast';

For further details, please see: UPDATE statement (Microsoft Access SQL)

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Maciej, thanks. Can this be integrated into the existing code?
Not sure, what you mean... Updating data is used to change its "content". Update command can NOT be used to select data. You have to be more clear. Please, provide sample data and expected result (improve your question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.