Jump to content


Photo

combine queries


  • Please log in to reply
3 replies to this topic

#1 tgavin

tgavin
  • Members
  • PipPipPip
  • Advanced Member
  • 176 posts
  • LocationNaples, FL

Posted 24 July 2006 - 04:04 PM

is it possible to combine the following 8 queries into 1 query?
$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'");
Thanks!
A noble spirit embiggens the smallest man.
- Jebediah Springfield

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 July 2006 - 04:10 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 tgavin

tgavin
  • Members
  • PipPipPip
  • Advanced Member
  • 176 posts
  • LocationNaples, FL

Posted 24 July 2006 - 05:07 PM

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.

Would I be better off just using the 8 queries I already have instead?
Thanks!
A noble spirit embiggens the smallest man.
- Jebediah Springfield

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 July 2006 - 05:20 PM

Well, if you're going to end up doing all 8 anyway, then probably.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users