Jump to content

SQL if statements


karldesign

Recommended Posts

Just a quick (and probably obvious) question...

 

In the past, I have used a standard query to first compare a userId from a login session with the userId of a database sample. From this, I could redirect if it isn't the user or keep the user on the page if it is them.

 

Having thought about it, there must be a quicker and more efficient way of doing this and wandered if there was an 'IF' statement that would do the same. (ie: UPDATE table WHERE row = get AND (IF row = session)).

Link to comment
Share on other sites

UPDATE table set id=id+1 WHERE row = get AND IF(row = session,TRUE,FALSE); I don't know it works or not

 

as per my knowledge it does not make any difference in performence prospective, it is always better if u use

 

UPDATE table set id=id+1 WHERE row IN ('get','session').

 

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.