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
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

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.