久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從字段與條件不匹配的表中選擇

Select from a table where fields don#39;t match conditions(從字段與條件不匹配的表中選擇)
本文介紹了從字段與條件不匹配的表中選擇的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我只是想知道我可以執(zhí)行什么樣的 SQL 命令來從某個表中選擇所有項目,其中 A 列不等于 x 列 B 不等于 x

I'm just wondering what kind of SQL command I could execute that would select all items from a certain table where column A is not equal to x and column B is not equal to x

類似于:

select something from table
where columna does not equal x and columnb does not equal x

有什么想法嗎?

推薦答案

關鍵是 sql 查詢,您將其設置為字符串:

The key is the sql query, which you will set up as a string:

$sqlquery = "SELECT field1, field2 FROM table WHERE NOT columnA = 'x' AND NOT columbB = 'y'";

請注意,有很多方法可以指定 NOT.另一個同樣有效的方法是:

Note that there are a lot of ways to specify NOT. Another one that works just as well is:

$sqlquery = "SELECT field1, field2 FROM table WHERE columnA != 'x' AND columbB != 'y'";

以下是如何使用它的完整示例:

Here is a full example of how to use it:

$link = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect to database");
mysql_select_db("$dbName") or die("Unable to select database $dbName");
$sqlquery = "SELECT field1, field2 FROM table WHERE NOT columnA = 'x' AND NOT columbB = 'y'";
$result=mysql_query($sqlquery);

while ($row = mysql_fetch_assoc($result) {
//do stuff
}

您可以在上述 while 循環(huán)中做任何您想做的事情.訪問表的每個字段作為 $row 數(shù)組 的一個元素,這意味著 $row['field1'] 將為您提供 field1 的值code> 在當前行上,$row['field2'] 將為您提供 field2 的值.

You can do whatever you would like within the above while loop. Access each field of the table as an element of the $row array which means that $row['field1'] will give you the value for field1 on the current row, and $row['field2'] will give you the value for field2.

請注意,如果列可能具有 NULL 值,則使用上述任一語法都無法找到這些值.您需要添加子句以包含 NULL 值:

Note that if the column(s) could have NULL values, those will not be found using either of the above syntaxes. You will need to add clauses to include NULL values:

$sqlquery = "SELECT field1, field2 FROM table WHERE (NOT columnA = 'x' OR columnA IS NULL) AND (NOT columbB = 'y' OR columnB IS NULL)";

這篇關于從字段與條件不匹配的表中選擇的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 综合久久av | 日本午夜一区二区三区 | 国产精品自产拍在线观看蜜 | 日韩a级片 | 精品日韩一区二区 | 96国产精品久久久久aⅴ四区 | 一区二区三区视频播放 | 欧美精品一区二区三区在线播放 | 国产亚洲精品久久久久动 | 免费av在线网站 | 成人区一区二区三区 | 日韩精品在线观看一区二区 | 亚洲欧美视频一区 | 中文字幕在线精品 | 夜夜爽99久久国产综合精品女不卡 | 亚洲国产精品99久久久久久久久 | 日韩在线视频一区二区三区 | 亚洲狠狠 | 亚洲人精品 | 久久r久久| av夜夜操 | www.久| 亚洲成人综合在线 | 亚洲自拍偷拍欧美 | 91久久精品国产91久久 | 亚洲国产成人精品久久久国产成人一区 | 亚洲成人黄色 | 久久91av | 免费视频一区二区 | 一级在线观看 | 欧美伊人 | 久久国产电影 | 97人澡人人添人人爽欧美 | 国产成人99久久亚洲综合精品 | 一区二区伦理电影 | 91视视频在线观看入口直接观看 | 国产乱码一二三区精品 | 久综合| 欧美久久一区二区三区 | 999视频| 亚洲第一在线 |