Jump to content

user_id=1 vs user_id=true


n8w

Recommended Posts

I am getting some unexpected results  and I think it's because in  my sql statement I am mixing up true when I want it to return just the literal match of user_id that is "1"

 

SELECT * FROM mytable WHERE user_id='1'

 

 

right now I think it's selecting everthing if the user_id is not empty .. hence it interprets user_id='1' as being true

 

How can I write this so it selects everything from table where the user_id literally is the number 1?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/261983-user_id1-vs-user_idtrue/
Share on other sites

Thanks Awjudd good advice

 

I just figured out the problem ... I was missing () on part of the statement

 

incorrect

SELECT * FROM mytable WHERE user_id=1 && c1 LIKE "%jj%" || c2  LIKE "%jj%"  ORDER BY c_timestamp DESC

 

correct

SELECT * FROM mytable WHERE user_id=1 && (c1 LIKE "%jj%" || c2 LIKE "%jj%" ) ORDER BY c_timestamp DESC

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.