Jump to content

[SOLVED] Query ?


ainoy31

Recommended Posts

Trying to query a table and one of the column can be values of either NULL, 0, or 1.

 

Here is my query

select complaint_flag, sessionid from table.orders where insert_date >= '2009-05-26' and order_status='done' and complaint_flag != '1' and complaint_flag is null

 

That should return about 1636 rows but it returns zero.  I am missing something here?

 

Much appreciation.  AM

Link to comment
Share on other sites

Hi

 

select complaint_flag, sessionid from table.orders

where insert_date >= '2009-05-26'

and order_status='done'

and complaint_flag != '1'

and complaint_flag is null

 

Why the 2 clauses? If the 2nd is true then the first is irrelevant.

 

All the best

 

Keith

Link to comment
Share on other sites

Here is my solution:

 

select complaint_flag, sessionid from govirs.orders where insert_date >= '2009-05-26' and order_status='done' and (complaint_flag != '1' or complaint_flag is null)

 

I needed a () around my OR statement.  I needed to account for the complaint_flag value to be null or zero.

 

Later. AM

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.