simon551 Posted July 9, 2007 Share Posted July 9, 2007 is there a mySql equivalent to the ms & '*' used in a query? I would use this to have a variable where if there is a condition then the variable would be either a number like 1 or 'all' Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/ Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Can you give an example SQL query? Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-293584 Share on other sites More sharing options...
simon551 Posted July 9, 2007 Author Share Posted July 9, 2007 SELECT tblActivities.ActivityID, tblActivities.Activity FROM tblActivities WHERE (((tblActivities.ActivityID) Like (33) & '*')); Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-293647 Share on other sites More sharing options...
davidz Posted July 9, 2007 Share Posted July 9, 2007 Not quite sure what the goal is here. Are you trying to say to show results where ActivityID is 33 and if there are no results to show everything? Side note: '*' is a wildcard is microsoft, in mySQL '%' means the same Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-293653 Share on other sites More sharing options...
simon551 Posted July 9, 2007 Author Share Posted July 9, 2007 that's how I have used it in ms access. I'm trying to do something like this, though, actually: if ($myRole='admin') { $act=%; } else $act=33; } Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-293680 Share on other sites More sharing options...
fenway Posted July 10, 2007 Share Posted July 10, 2007 that's how I have used it in ms access. I'm trying to do something like this, though, actually: if ($myRole='admin') { $act=%; } else $act=33; } Huh? Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-294642 Share on other sites More sharing options...
simon551 Posted July 10, 2007 Author Share Posted July 10, 2007 That seems to be working. Am I crazy for doing it this way? if ($myRole='admin') { $act=%; } else { $act=33; } query: SELECT tblActivities.ActivityID, tblActivities.Activity FROM tblActivities WHERE (((tblActivities.ActivityID) Like '$act')); Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-294675 Share on other sites More sharing options...
Illusion Posted July 10, 2007 Share Posted July 10, 2007 it should be if($myRole=='admin') ur code always sets $act='%' Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-294710 Share on other sites More sharing options...
fenway Posted July 11, 2007 Share Posted July 11, 2007 it should be if($myRole=='admin') ur code always sets $act='%' That will match everything... why not just drop the where clause. Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-295386 Share on other sites More sharing options...
Illusion Posted July 11, 2007 Share Posted July 11, 2007 I didn't really bother about what $act variable contain , I just said that if condition is wrong.Yeah I know '%' returns all the records , may be that is what he want. Quote Link to comment https://forums.phpfreaks.com/topic/59123-solved/#findComment-295452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.