Query of two or more mssql Pdo tables

Asked

Viewed 35 times

0

Query of two or more mssql Pdo tables, the connection is normal.

I’m having a little trouble.

I have 2 tables.

profile

id | name | birth date | Address

connections

id | idperfil | data

I’m trying to call the two tables for the logged-in user to have access, but when I try nothing appears. When I use only calling a table appears more when I call both only appears the one that comes first in order.

How is my script:

$sql2 = "select nome, datanascimento, Endereço from perfil where id = '$id'";
$stm2 = $conn->prepare($sql2);  
$stm2->execute();  
$row = $stm2->fetch(PDO::FETCH_ASSOC);

$sql3 = "select id, data from conexoes where idperfil = '$id'";
$stm3 = $conn->prepare($sql3);  
$stm3->execute();  
$roww = $stm3->fetch(PDO::FETCH_ASSOC);

When it’s time to call, I use the

<?php echo $roww['DisConnectTM'];?>
  • pq does not make a single select with Join between the two tables?

  • I didn’t understand the doubt very well but is it possible to do a JOIN between the 2 tables and so just make a query? Because there is the ID and IDPROFILE, if they are the same value you can do this JOIN and filter by the ID of the person later.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.