Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
Who's Online
1 registered (Gardener), 18 Guests and 19 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 06/13/06
Posts: 86
Top Posters (30 Days)
Ruben Rocha 179
Gizmo 112
Rick 109
Thelockman 80
driv 43
AllenAyres 35
ntdoc 28
Ian 24
Sirdude 23
ScriptKeeper 20
Latest Photos
My Home System
test photo gallery
Bernese Mountain Dogs
My Daimler
Dorado and shark
Page 1 of 2 1 2 >
Topic Options
Rate This Topic
#216413 - 08/11/08 08:51 PM SQL Assistance
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
Due to usergroup issues from the upgrade, I need to update everyone's usergroup who is a guest to user
Code:
UPDATE ubbt_USER_GROUPS SET GROUP_ID = '4' WHERE GROUP_ID = '5'


Except for USER_ID #1.

:help:
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
#216414 - 08/11/08 09:00 PM Re: SQL Assistance [Re: AllenAyres]
Sirdude Offline

*****

Registered: 04/19/07
Posts: 2077
Loc: SoCal, USA
add 'AND USER_ID > 1' to the clause

bada bing! smile
_________________________


Top
#216422 - 08/12/08 07:40 AM Re: SQL Assistance [Re: Sirdude]
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
thank you, I had something similar, but of course it was erroring out.
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
#216423 - 08/12/08 07:42 AM Re: SQL Assistance [Re: AllenAyres]
blaaskaak Offline

****

Registered: 08/30/06
Posts: 1299
Loc: Breda, NL
Statement can still error out if a user was already in group 4 also.
_________________________

Top
#216424 - 08/12/08 07:43 AM Re: SQL Assistance [Re: AllenAyres]
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
I'm getting the same error:

SQL Error: Duplicate entry '6-4' for key 1

I've tried this:

UPDATE ubbt_USER_GROUPS SET GROUP_ID = '4' WHERE GROUP_ID = '5' AND USER_ID > '1'

and this:

UPDATE ubbt_USER_GROUPS SET GROUP_ID = '4' WHERE GROUP_ID = '5' AND USER_ID > 1

and get the same error.
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
#216425 - 08/12/08 08:20 AM Re: SQL Assistance [Re: AllenAyres]
blaaskaak Offline

****

Registered: 08/30/06
Posts: 1299
Loc: Breda, NL
The query goes wrong because there are already people in group 4 AND in group 5. 5 wants to change to 4, but 4 is already there, so it errors out because of the index settings.

Do this one before:

delete from ubbt_USER_GROUPS where GROUP_ID = 5 and USER_ID in (select USER_ID from ubbt_USER_GROUPS where GROUP_ID = 4)

Not exactly sure about this one, backup the table first please smile This would remove anyone from group 5 if they are already in group 4.
_________________________

Top
#216426 - 08/12/08 08:28 AM Re: SQL Assistance [Re: AllenAyres]
Rick Administrator Offline

*****

Registered: 06/04/06
Posts: 7898
Loc: Aberdeen, WA
Best way would probably just to get rid of everyone in group 5 and then if you have MySQL 4.1+ you can add everyone to the user's group that isn't already in a group.

Sql Query:
delete from ubbt_USER_GROUPS where GROUP_ID='5' and USER_ID > 1


and then:


Sql Query:
insert ubbt_USER_GROUPS(
    select ubbt_USERS.USER_ID, 4
    from ubbt_USERS
    where ubbt_USERS.USER_ID not in (
        select ubbt_USER_GROUPS.USER_ID
        from ubbt_USER_GROUPS
    )
    and ubbt_USERS.USER_ID <>1
)


On another note, I need to figure out why this is happening for some people. Out of all the ugprades I've done, I haven't had this happen.
_________________________
UBB.threads™ Developer
My Personal Website · StogieSmokers.com

Top
#216430 - 08/12/08 01:04 PM Re: SQL Assistance [Re: Rick]
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
Thank you, I ended up using phpmyadmin to backup the table, edit it in ultraedit then truncate and re-install.

This particular site shows MySQL:

Client API version 3.23.58

The web host claims the server install is 4.something, but maybe the difference is the issue? I always see errors here not seen on other sites when I update it - just when I think it's safe to upgrade the bottom falls out and something simple isn't.
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
#216432 - 08/12/08 02:25 PM Re: SQL Assistance [Re: AllenAyres]
Rick Administrator Offline

*****

Registered: 06/04/06
Posts: 7898
Loc: Aberdeen, WA
Hmm, the first thing I'd do is verify the version of MySQL itself. If you run the following SQL command you can get it:

show variables

Towards the bottom you'll see the version variable that will give you the actual version running.
_________________________
UBB.threads™ Developer
My Personal Website · StogieSmokers.com

Top
#216435 - 08/12/08 03:55 PM Re: SQL Assistance [Re: Rick]
David Dreezer Offline
Pooh-Bah
*****

Registered: 07/21/06
Posts: 1792
AA, that is the MySQL client built into your php, NOT the version of MySQL itself. Rick's show variables will give you the version of MySQL. Note that the older MySQL client you have in your php might limit some of the things you can do with MySQL because that client doesn't know how to ask MySQL to do them.
_________________________
What do you mean "You're the bomb, run away?"

Top
Page 1 of 2 1 2 >


Moderator:  Gizmo 
Shout Box

Today's Birthdays
brushie, cass, Monte G., twebman, White Gold Wielder
Recent Topics
Shrinking graemlins
by Djuma
Today at 05:48 PM
2 problems I'm seeing now.
by DougMM
Today at 04:39 PM
Which CSS Style Controls the bottom lines
by David DelMonte
Today at 01:51 PM
UBBThreads vs. vBulletin -- Defections & Why So Tough to Compare?
by WebMagic
Today at 12:28 PM
Font and column shifts occuring
by Bill B
Yesterday at 06:21 PM
Forum Stats
4261 Members
33 Forums
30532 Topics
154962 Posts

Max Online: 978 @ 06/24/07 08:19 PM