PHP PDO-从查询中排除特定行
我正在使用PDO连接到我的数据库。我想执行一个查询并仅从查询中排除某一行。我不知道怎么做 根据我从另一个问题得到的建议,我发布了这是我目前的解决方案,但它不起作用PHP PDO-从查询中排除特定行,php,mysql,pdo,Php,Mysql,Pdo,我正在使用PDO连接到我的数据库。我想执行一个查询并仅从查询中排除某一行。我不知道怎么做 根据我从另一个问题得到的建议,我发布了这是我目前的解决方案,但它不起作用 $queryProfileCode = $dbh->prepare("SELECT profile_code FROM tableBusinessProfiles WHERE profile_code = ? AND NOT EXISTS(SELECT * FROM tableBusinessProfiles WHERE pro
$queryProfileCode = $dbh->prepare("SELECT profile_code FROM tableBusinessProfiles WHERE profile_code = ? AND NOT EXISTS(SELECT * FROM tableBusinessProfiles WHERE profile_code = $businessProfileIDUrl)");
$queryProfileCode->bindValue(1,$profileCode);
$queryProfileCode->execute();
$resultTableProfileCode = $queryProfileCode->fetchAll();
我找不到如何从查询中排除特定记录。我不确定您试图实现什么?问题是查询 如果配置文件代码不等于$businessProfileIDUrl,是否从tableBusinessProfiles获取所有配置文件代码 查询可以是:
SELECT profile_code FROM tableBusinessProfiles WHERE profile_code != $businessProfileIDUrl
您的查询应该是
SELECT
profile_code
FROM tableBusinessProfiles
WHERE
profile_code != $businessProfileIDUrl
或
MySQL“不等于”运算符是!=和**需要排除哪些记录?它符合什么条件?
SELECT
profile_code
FROM tableBusinessProfiles
WHERE
id NOT IN ($businessProfileIDUrl);