Inner joins query don't display data if added extra conditions in WHERE clause

Hi

Guys is anyone can help with this query, this is a first time that i have a problem like this without any error.

I am using Heidisql to test stuff.

Here is a query that works and displaying data

SELECT b.status, b.symbol, b.order_type, b.price_open, b.time_open, b.size, b.plpips, c.bid
FROM www_users a
INNER JOIN trade_log b ON b.uid = a.id
INNER JOIN currency_rates c ON c.uid = a.id
WHERE b.uid = '23' AND b.status = 'Open'

and now if i add extra condition after ‘Open’ AND b.order_type = '1' AND b.order_type = '0' then i don’t have data anymore, but if i try to add only one condition, then i get results.

Here is 4 images to see what this is about

1st image without adding extra conditions for sorting out order_type
https://image.prntscr.com/image/3Sj3VtaORuuwCGZ6PoZrYA.png

2nd image with one extra condition for sorting out order_type 1


3rd image with one extra condition for sorting out order_type 0
https://image.prntscr.com/image/1dHBHWdoRNqDRAbRsdlW3Q.png

4th image with two extra conditions for sorting your out results 1 and 0 from order_type
https://image.prntscr.com/image/6y2Bj68zQ7G_iIu_IJ9kvA.png

EDIT:

SOLVED, i forgot about BETWEEN :smiley:

WHERE b.uid = '23' AND b.status = 'Open' AND b.order_type BETWEEN '0' AND '1'

OR IN (my preference)

WHERE b.uid = '23'
  AND b.status = 'open'
  AND b.order_type IN ('0', '1')

Or even the old fashioned OR clause with parenthesis

WHERE b.uid = '23'
  AND b.status = 'open'
  AND (b.order_type = '0' OR b.order_type =  '1')
1 Like

AND b.order_type = '1' AND b.order_type = '0'

just to wrap up why this didn’t work, you are asking each value of order type to be equal to two different things at the same time

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.