[英]PHP PDO - Exclude a particular row from a query
I am working with PDO to connect to my database. 我正在使用PDO连接到数据库。 I would like to perform a query and exclude a particular row from my query only.
我想执行查询并仅从查询中排除特定的行。 I'm not sure how to do it.
我不确定该怎么做。
From the suggestions I got from another question, I posted this is my current solution right now but it doesn't work 根据我从另一个问题得到的建议,我现在发布了这是我当前的解决方案,但是它不起作用
$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();
I couldn't find how to exclude a particular record from my query. 我找不到如何从查询中排除特定记录。
your query should be 您的查询应该是
SELECT
profile_code
FROM tableBusinessProfiles
WHERE
profile_code != $businessProfileIDUrl
or 要么
SELECT
profile_code
FROM tableBusinessProfiles
WHERE
id NOT IN ($businessProfileIDUrl);
The MySQL "not equal to" operaters are != and <>** MySQL的“不等于”运算符是!=和<> **
I'm not sure what you try to achieve? 我不确定您要达到什么目标? The problem is the query?
问题是查询?
Do you want to get ALL profile_codes FROM tableBusinessProfiles WHERE profile_code DOES NOT EQUAL TO $businessProfileIDUrl
? 您是否
get ALL profile_codes FROM tableBusinessProfiles WHERE profile_code DOES NOT EQUAL TO $businessProfileIDUrl
吗?
The query could then be: 该查询可能是:
SELECT profile_code FROM tableBusinessProfiles WHERE profile_code != $businessProfileIDUrl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.