存储过程连接转换为PHP

时间:2011-10-14 09:14:01

标签: php mysql sql-server database stored-procedures

我有一个T-SQL存储过程连接,我需要转换为MySQL连接。我不确定确切的语法。

T-SQL代码:

    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

2 个答案:

答案 0 :(得分:2)

$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    ^      ^

答案 1 :(得分:1)

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

我希望wattsure是DB名称.... 希望这会有所帮助...