Someone who manages PDO bindParam, I would greatly appreciate your help [closed]

-2

SELECT * from contact_company inner join company on company.id_company = company_contact.business_enterprise WHERE contact_state = 'ACTIVE' AND company_contact_id! = 0

    
asked by Keane 16.09.2017 в 00:36
source

2 answers

0

I hope it is what you are looking for:

Bring all active contacts, from all companies

$stmt = $db->prepare('SELECT * from contacto_empresa INNER JOIN empresa ON empresa.id_empresa = contacto_empresa.empresa_id_empresa WHERE contacto_empresa.estado = 'ACTIVO');
$stmt->execute()

Bring all the active contacts for a particular company (Una Sola), passing the id of the company in $idEmpresa

$stmt = $db->prepare('SELECT * from contacto_empresa INNER JOIN empresa ON empresa.id_empresa = contacto_empresa.empresa_id_empresa WHERE contacto_empresa.estado = 'ACTIVO' AND id_contacto_empresa = :idEmpresa');
$stmt->bindParam('idEmpresa', $idEmpresa);
$stmt->execute()
    
answered by 16.09.2017 / 17:59
source
0

It would be something like this: -

$stmt = $db->prepare('SELECT * from contacto_empresa inner join empresa on empresa.id_empresa = contacto_empresa.empresa_id_empresa WHERE estado_contacto = :estado AND id_contacto_empresa != :idEmpresa');

 $stmt->bindParam(':estado', 'ACTIVO');
 $stmt->bindParam('idEmpresa', '0');

 $stmt->execute()
    
answered by 16.09.2017 в 13:20