lmpearce1
lmpearce1

Reputation: 179

Stored procedure join converted to PHP

I have a T-SQL stored procedure join which I need to convert to a MySQL join. I'm not sure of the exact syntax.

T-SQL code:

    SELECT username
    FROM wattsure..be_user_profiles bup
    JOIN wattsure..be_users bu
    ON bup.user_id = bu.id
    WHERE company_name = @installer
    AND [group] = 6

Upvotes: 0

Views: 191

Answers (2)

Karthik
Karthik

Reputation: 1091

SELECT username FROM  wattsure.be_user_profiles bup
INNER JOIN wattsure.be_users bu
ON bup.user_id = bu.id
WHERE company_name = '$var'
AND `group` = 6

I hope wattsure is DB name.... Hope this helps...

Upvotes: 1

Johan
Johan

Reputation: 76641

$param = mysql_real_escape_string($param); 
//at the least, or use PDO.

$query = "SELECT username
          FROM wattsure.be_user_profiles bup
          INNER JOIN wattsure.be_users bu
          ON bup.user_id = bu.id
          WHERE company_name = '$param' AND `group` = '6' ";
//Don't forget these quotes    ^      ^

Upvotes: 2

Related Questions