Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: DBI match both empty and undef

by pme (Prior)
on Jan 27, 2019 at 15:21 UTC ( #1229026=note: print w/replies, xml ) Need Help??


in reply to DBI match both empty and undef

Hi,

What kind of database you have? For example in Oracle database the empty string becomes null automagically. This is how to select rows where both Tag1 and Tag2 is null. null value in the database is seen as undef in perl. I suppose you use DBI module.

SELECT * FROM GlossaryMetadata WHERE Tag1 is null AND Tag2 is null;

Replies are listed 'Best First'.
Re^2: DBI match both empty and undef
by Anonymous Monk on Jan 27, 2019 at 16:05 UTC

    SQLite and MSSQL. Both make a difference between undef and empty, and I would like to match both.

      SELECT * FROM GlossaryMetadata WHERE (Tag1 is null or Tag1 = '') AND ( +Tag2 is null or Tag2 = '');

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1229026]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2019-11-12 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (66 votes). Check out past polls.

    Notices?