Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
Who's Online
4 registered (David DelMonte, Djuma, ECNet, 1 invisible), 16 Guests and 19 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 01/10/04
Posts: 1703
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
#216438 - 08/12/08 06:08 PM Re: SQL Assistance [Re: David Dreezer]
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
version 4.1.21-standard

I understand what you're saying... for some reason I can import a hundred sites and not have a problem, but this one always gives me issues - not sure what it is.
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
#216442 - 08/13/08 07:46 AM Re: SQL Assistance [Re: AllenAyres]
Pappy Farland Offline
journeyman
*****

Registered: 01/01/04
Posts: 70
I am using 5.0.45 are there any known issues with version 5+?

(sorry not trying to Hijack the thread)

Top
#216448 - 08/13/08 11:17 AM Re: SQL Assistance [Re: Pappy Farland]
Sirdude Offline

*****

Registered: 04/19/07
Posts: 2077
Loc: SoCal, USA
nope -- i'd highly recommend going to latest (release) of mysql.. same for apache and php..

i run all of em on my sites.
_________________________


Top
#216451 - 08/13/08 08:24 PM Re: SQL Assistance [Re: Sirdude]
ntdoc Offline

***

Registered: 11/08/06
Posts: 3202
Agreed - no problems for me either. I had my hosting provider put me on another server that was running the latest versions and all works for me.

Top
#216452 - 08/13/08 08:37 PM Re: SQL Assistance [Re: ntdoc]
Sirdude Offline

*****

Registered: 04/19/07
Posts: 2077
Loc: SoCal, USA
i'd also recommend Linux box vs Windows box, if at all possible.. many reasons for this..

some peeps may not be able to change OSes, but if you are starting fresh, go *Nix
_________________________


Top
#216458 - 08/14/08 08:23 PM Re: SQL Assistance [Re: Sirdude]
AllenAyres Offline

****

Registered: 12/29/03
Posts: 1639
Loc: Texas
Server 2008 is looking pretty suite smile
_________________________
- Allen
- ThreadsDev | PraiseCafe

Top
Page 1 of 2 1 2 >


Moderator:  Gizmo 
Shout Box