Luis
Luis

Reputation: 313

How to combine OR & AND to work as you think it should do

I'm blocked with a very simple Query that it's not working as I think it should do.

What I want to retrieve is all the rows that:

What I'm getting:

I'm pretty sure that I'm missing a stupid thing but I can't see it.

Here you have an example of my generated Query:

SELECT *
FROM (`solicitudes`)
WHERE `status` = '4'
OR `end` < 1289418069
AND `user_id` = '2'
AND `segundamano` = '1'

PS: Sorry guys if this is a silly question, any direction will be much appreciated. Thanks in advance.

Upvotes: 0

Views: 36

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799450

SELECT *
FROM (`solicitudes`)
WHERE (`status` = '4'
  OR `end` < 1289418069)
  AND `user_id` = '2'
  AND `segundamano` = '1'

Upvotes: 1

Related Questions