vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   What query would I use here? (https://vborg.vbsupport.ru/showthread.php?t=39900)

Parker Clack 06-15-2002 08:37 PM

What query would I use here?
 
I am wanting to do an update to my post table where I have added a column called usergroupid and I want to run a query on the database so that if the table user has a userid with a usergroupid of 9 I want it to set the usergroupid in the table post to 9 for that same userid.

Any suggestions?

Thanks,
Parker

Logician 06-15-2002 09:19 PM

Good question.

Although

[SQL]
update post SET post.usergroupid = user.usergroupid FROM user WHERE post.userid = user.userid AND user.usergroupid=9;
[/SQL]

is the SQL command (which works in MSSQL and Oracle) you asked, AFAIK MYSQL does not support multi-tabled UPDATE commands. Give it a shot in a test db but I dont think it will work.

Parker Clack 06-15-2002 09:39 PM

Logician:

Sorry. You were correct. This returned a syntax error near 'FROM user WHERE post.userid = user.userid AND user.usergroupid=9' at line 1

Humm.........any other ideas?

Parker

Logician 06-16-2002 09:30 AM

If I'm correct that MYSQL does not support multi-tabled updates you cant do it with SQL (BTW.MYSQL does not support looped SELECTs either).

Your best bet is to write a small PHP script which will go through both tables and update your relevant field.

Parker Clack 06-16-2002 12:18 PM

Logician:

That is exactly what I did to get it to work. I just wrote a small script and all is well.

Thanks for the suggestions.

Parker


All times are GMT. The time now is 10:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01032 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete