Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:20:47+00:00 2026-06-05T23:20:47+00:00

SELECT 1 FROM dual where trim(‘X ‘) = ‘X’ Gives 1. SELECT 1 FROM

  • 0
SELECT 1 FROM dual where trim('X ') = 'X'

Gives 1.

SELECT 1 FROM dual where trim(' ') = ''

Gives no rows.

Is there an easy way to select all rows where field is whitespace short of regex?

Is there a way to “trick” TRIM into TRIMming ' ' and giving ''?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:20:49+00:00Added an answer on June 5, 2026 at 11:20 pm

    In Oracle, the empty string is NULL. So the conventional approach would be something like

    SELECT 1 
      FROM dual 
     WHERE trim(' ') IS NULL
    

    That will also, of course, return results where the column is NULL. If you want cases where the column is non-NULL and is solely composed of spaces

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (
      2    select 1 id, ' ' str from dual union all
      3    select 2, null from dual union all
      4    select 3, 'a' from dual
      5  )
      6  select *
      7    from t
      8   where trim(str) is null
      9*    and str is not null
    SQL> /
    
            ID S
    ---------- -
             1
    

    Just to round out the answer, if you want to use a simple regexp_like as well

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (
      2    select 1 id, ' ' str from dual union all
      3    select 2, null from dual union all
      4    select 3, 'a ' from dual
      5  )
      6  select *
      7    from t
      8*  where regexp_like( str, '^[[:space:]]+$' )
    SQL> /
    
            ID ST
    ---------- --
             1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The query select 1 from dual where false returns 0 rows, but the query
Why doesn't it work? SELECT a.* FROM dual a JOIN (SELECT * FROM dual
select 'true' from dual where 1 not in (null,1); when we execute this which
I'd like to run statements like SELECT date_add('2008-12-31', 1) FROM DUAL Does Hive (running
Is trunc and round the same with negative arguments? SQL> select round(123456.76,-4) from dual;
I have a Varchar day column and I would like to select all rows
Can anyone please explain the below SQL statement from Oracle DB: select decode(TRIM(to_char(SYSDATE,'Day')),'Monday','3','1') from
In Oracle, I can SELECT sysdate FROM dual to get the current system date/time.
Let's take this query: WITH temp as SELECT '123455' colum from dual SELECT *
I tried the below sql query INSERT INTO test.ACT_QUERY values(2139,2,'SELECT ''D'',ORDER_ID from dual'); When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.