搜尋
首頁專題Accessaccess刪除空白欄位記錄

access刪除空白欄位記錄

Dec 01, 2020 pm 03:46 PM
access空白字段記錄

access刪除空白欄位記錄

首先我們需要知道在Access中null和空字串是不同的,因此如果處理不好該問題就會帶來不少麻煩,特別是在混合查詢中。

(推薦教學:access資料庫學習

解決方法如下:

var
 SQLStr:string;
begin
//
  SQLStr := 'select * from ordertb where 1>0';
  if Trim(Edit1.Text)<>&#39;&#39; then
  SQLStr := SQLStr +&#39; and serialid like :a&#39;;
  if Trim(Edit2.Text)<>&#39;&#39; then
  SQLStr := SQLStr +&#39; and pname like :b&#39;;
 
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add(SQLStr);
    if Trim(Edit1.Text)<>&#39;&#39; then
    Parameters.ParamByName(&#39;a&#39;).Value := &#39;%&#39;+Trim(Edit1.Text)+&#39;%&#39;;
    if Trim(Edit2.Text)<>&#39;&#39;then
    Parameters.ParamByName(&#39;b&#39;).Value := &#39;%&#39;+Trim(Edit2.Text)+&#39;%&#39;;
    Open;
  end;
end;

或:

begin  
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add(&#39;select * from ordertb where 1>0&#39;);
    if Trim(Edit1.Text)<>&#39;&#39; then
    SQL.Add(&#39; and serialid like &#39;&#39;%&#39;+Trim(Edit1.Text)+&#39;%&#39;&#39;&#39;);
    if Trim(Edit2.Text)<>&#39;&#39;then
    SQL.Add(&#39; and pname like &#39;&#39;%&#39;+Trim(Edit2.Text)+&#39;%&#39;&#39;&#39;);
    Open;
  end;
end;

總結:

將條件為空的欄位從查詢語句中篩選掉。

以上是access刪除空白欄位記錄的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:csdn。如有侵權,請聯絡admin@php.cn刪除

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具