1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] How can I solve an problem with two select statements in one query

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 17, 2024 às 04:23.

  1. Stack

    Stack Membro Participativo

    I want to retrieve og tags with sql in php language but I only get to see 1 result, that is the first one he reads, the other I don't get to see in page source.

    this is the code with php.

    $query = "SELECT metatitle FROM isacontent_content WHERE contentid = 12245
    UNION ALL
    SELECT name FROM isacontent_module_anchorimage WHERE contentid = 12245";

    $resimage = $conn->query($query);

    if(is_array($resimage)){

    foreach ($resimage as $resItem){

    $metaData[] = $resItem->fetch_assoc();

    }

    }else{

    $metaData[] = $resimage->fetch_assoc();

    }
    $title = $metaData[0]["metatitle"];
    $image = $metaData[0]["name"];


    I expect that both select statements will work and I can see both contents in the meta tags

    Continue reading...

Compartilhe esta Página