1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mySQL output as JSON not gathering all rows

Discussion in 'MySQL' started by Stealthrtt, Jan 8, 2022.

  1. #1
    Hey all the example below is what I currently get when I run the query below:
    
    {
      "data": [{
                    "id": "546789434",
                    "photo": "rru7ehklu.jpg"
                 }, {
                    "id": "546789434",
                    "photo": "934bu9rg9w3rg.jpg"
                 },
                  ..........
                 {
                    "id": "546789434",
                    "photo": "er6u57kerethu]}
    
    Code (markup):
    Using this query here:
    SELECT
        CONCAT("{""data"": [",
             GROUP_CONCAT(
                  CONCAT("{""id"":""",fbid,""","),
                  CONCAT("""photo"":""",photoName,"""}")
             )
        ,"]}")
    AS json FROM fbphotos;
    Code (SQL):
    This does produce the needed schema but the two issues are:
    1. There are 440 rows in the fbphotos table and yet this JSON output only has 13...
    2. It truncates abruptly at the 13 row data while it is creating the output.
    If I do a SELECT fbid, photoName FROM fbphotos I get back all 440 rows without an issue.
    SEMrush
    [​IMG]

    I checked the 13th row in the fbphotos table and the photo name was like every other one that came before and after it so its not caused by some type of special character or anything making it end abruptly.

    What could I be missing?
     
    Stealthrtt, Jan 8, 2022 IP
    SEMrush