lakeshoretech Posted November 11, 2010 Share Posted November 11, 2010 Can someone take a look at this? I'm trying to add a 2nd case condition to my where statement. This works perfectly UNTIL I add the second CASE, then I get no output whatsoever. Variables are from a user form. When I hard code these, it pulls correctly (one at a time). Am I missing something obvious here? WHERE.... uba_players.player_status <> '7 - Quit' AND (CASE $player_age WHEN 999 THEN uba_players.player_age like '%' AND ELSE uba_players.player_age = $player_age AND END) (CASE '999' WHEN 999 THEN uba_players.player_status like '%' ELSE uba_players.player_age = $player_status END) ORDER BY..... Quote Link to comment https://forums.phpfreaks.com/topic/218356-using-multiple-case-conditions-php-sql/ Share on other sites More sharing options...
lakeshoretech Posted November 11, 2010 Author Share Posted November 11, 2010 To explain the reason for the CASE statement (I would use something else if recommended) User has two choices before they pull the search. 1) AGE (player_age) - ALL ages = 999, or a specific age selection AND 2) STATUS (player_status) - ALL status = 999, or a specific status selection (on the 2nd case, I'm just trying to get it to work at all with a hard coded 999) Quote Link to comment https://forums.phpfreaks.com/topic/218356-using-multiple-case-conditions-php-sql/#findComment-1132918 Share on other sites More sharing options...
mikosiko Posted November 11, 2010 Share Posted November 11, 2010 .... (CASE $player_age WHEN 999 THEN uba_players.player_age like '%' AND ELSE uba_players.player_age = $player_age AND END) (CASE '999' WHEN 999 THEN uba_players.player_status like '%' ELSE uba_players.player_age = $player_status END) ORDER BY.... 2 "AND" in the first CASE are wrong... try .... (CASE $player_age WHEN 999 THEN uba_players.player_age like '%' ELSE uba_players.player_age = $player_age END) AND (CASE '999' WHEN 999 THEN uba_players.player_status like '%' ELSE uba_players.player_age = $player_status END) ORDER BY.... Quote Link to comment https://forums.phpfreaks.com/topic/218356-using-multiple-case-conditions-php-sql/#findComment-1133148 Share on other sites More sharing options...
lakeshoretech Posted November 12, 2010 Author Share Posted November 12, 2010 That was it. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/218356-using-multiple-case-conditions-php-sql/#findComment-1133349 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.