Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my table

example 1
user | status | unit | date
1 | 0 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01

example 2
user | status | unit | date
1 | 2 | 1 | 2015-01-01
1 | 2 | 2 | 2015-01-01



I only want a result when this is true
(When user = 1 and status = 2 and datum = 2015-01-01)

example 1 should give me 0 records
example 2 should give me 1 record
Posted
Comments
Kornfeld Eliyahu Peter 23-Jun-15 7:09am    
Andy Lanng 23-Jun-15 7:37am    
Please check your question. Example 1 result will be 1 and example 2 will be 2
Tomas Takac 23-Jun-15 7:43am    
You should use SQL[^]... But honestly, what's the problem here?
John C Rayan 23-Jun-15 7:53am    
Andy L is right. Based on your condition the results that you expect are wrong.Check Andy Lanng's reply.

If you add unit=1 in your condition then you get what you expect.

Explain to us a bit more clearer.

1 solution

SQL
Assuming that the columns user, status and unit are int , the following should give you wanted.

SELECT *
FROM your_table
WHERE user=1 AND
status=2 AND
unit=1 AND
[date] = '2015-01-01'
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900