0

JSON format is new to me and I am trying to understand how I can apply searches within those JSON strings.

In this situation I have a player table where two critical columns exists. The first column is a standard text Names. The next is a JSON string that holds various player information. For the sake of this question, I need two extracts from it. $.firstname and $.lastname. The challenge for me here is that I need to produce a query that lists any rows where all 3 data match. The function of this is to detect and list players that have duplicate characters.

In my standard query to list all I use.

SELECT
    Name,
    json_extract(charinfo, '$."firstname"') AS Firstname,
    json_extract(charinfo, '$."lastname"') AS Lastname,
FROM players
ORDER BY Firstname;

What I have currently is"

SELECT
    Name,
    json_extract(charinfo, '$."firstname"') AS Firstname,
    json_extract(charinfo, '$."lastname"') AS Lastname,
    COUNT(*) AS qty, license
FROM players
GROUP BY NAME, Firstname, Lastname HAVING COUNT(*)> 1
ORDER BY Firstname;

While this works, I would like it to display the duplicate rows, not just count them. And I'm not sure the correct way to make that adjustment.

Rigz Gx
  • 29
  • 3

0 Answers0