The Little Guy Posted December 2, 2006 Share Posted December 2, 2006 I have never tried this before, but can if/elseif/else statements (or something similar) somehow be placed in a MySQL SQL query? If so, could I get an example of how it would be done? Link to comment https://forums.phpfreaks.com/topic/29185-mysql-ifelseifelse-statements/ Share on other sites More sharing options...
jsladek Posted December 2, 2006 Share Posted December 2, 2006 You can use the if elseif else and write the sql in each one.if ( $x == $x) { $sql = "SELECT * FROM tableA"; } elseif ($x == $y) { $sql = "SELECT * FROM tableB"; } else {$sql = "SELECT * FROM tableC"; } -John Link to comment https://forums.phpfreaks.com/topic/29185-mysql-ifelseifelse-statements/#findComment-133797 Share on other sites More sharing options...
The Little Guy Posted December 2, 2006 Author Share Posted December 2, 2006 That way takes too much time, I would like something like this:[CODE]IF search_condition THEN statement_list [ELSEIF search_condition THEN statement_list] ... [ELSE statement_list]END IF[/CODE]It would be nice if I could get an example of that though. Link to comment https://forums.phpfreaks.com/topic/29185-mysql-ifelseifelse-statements/#findComment-133801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.