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
https://forums.phpfreaks.com/topic/58549-sql-if-statements/
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
https://forums.phpfreaks.com/topic/58549-sql-if-statements/#findComment-290583
Share on other sites

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.