tgavin Posted July 24, 2006 Share Posted July 24, 2006 is it possible to combine the following 8 queries into 1 query?[code] $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($theme)."' WHERE pref_name = 'theme'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($tooltips)."' WHERE pref_name = 'tooltips'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($icnsize)."' WHERE pref_name = 'icons'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($updates)."' WHERE pref_name = 'updates'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($confirm_msgs)."' WHERE pref_name = 'confirm_msgs'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($new_sub_notify)."' WHERE pref_name = 'new_sub_notify'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($sub_activation)."' WHERE pref_name = 'sub_activation'"); $sql = mysql_query("UPDATE prefs SET pref_value = '".strip($show_pagination)."' WHERE pref_name = 'show_pagination'");[/code]Thanks! Link to comment https://forums.phpfreaks.com/topic/15504-combine-queries/ Share on other sites More sharing options...
fenway Posted July 24, 2006 Share Posted July 24, 2006 Sure... you can use the oft-forgotten CASE statment; it would be a really long and ugly query, but it will get the job done. Check the refman for the syntax, I haven't used it in years. Link to comment https://forums.phpfreaks.com/topic/15504-combine-queries/#findComment-62939 Share on other sites More sharing options...
tgavin Posted July 24, 2006 Author Share Posted July 24, 2006 [quote author=fenway link=topic=101692.msg402649#msg402649 date=1153757428]Sure... you can use the oft-forgotten CASE statment; it would be a really long and ugly query, but it will get the job done. Check the refman for the syntax, I haven't used it in years.[/quote]Would I be better off just using the 8 queries I already have instead?Thanks! Link to comment https://forums.phpfreaks.com/topic/15504-combine-queries/#findComment-62990 Share on other sites More sharing options...
fenway Posted July 24, 2006 Share Posted July 24, 2006 Well, if you're going to end up doing all 8 anyway, then probably. Link to comment https://forums.phpfreaks.com/topic/15504-combine-queries/#findComment-62999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.