Welcome Guest, Not a member yet? Register   Sign In
Sql help for update query
#1

[eluser]debow[/eluser]
Hello all, I'm posting there here because I'm using CI for my site. I know this is more a mysql question but thought I'd try.

What I'm trying to do is take the below select that works for the most part as a select and covert it to an update as well which I'm having problems with around the JOIN.

This is the select I'm working off of.

Code:
SELECT id, name, result, event
,      FIND_IN_SET(
            result
        ,  (SELECT  GROUP_CONCAT(
                        DISTINCT result
                        ORDER BY result
                    )
            FROM    eresults where event='100m' and result !='DNC')
        ) as rank
FROM   eresults where event='100m';

My table consist of another column called eventrank. I want to take the value of rank and set the eventrank to the same based off the id etc. I'm trying something like below but its not working.

Code:
UPDATE eresults
JOIN
SELECT id, name, result, event
,      FIND_IN_SET(
            result
        ,  (SELECT  GROUP_CONCAT(
                        DISTINCT result
                        ORDER BY result
                    )
            FROM eresults where event='100m' and result !='DNC')
        ) as rank
FROM eresults where event='100m'
SET eventrank = rank where eresults.id=rank.id;

Any help would be appreciated. Thanks


Messages In This Thread
Sql help for update query - by El Forum - 11-09-2010, 01:59 PM
Sql help for update query - by El Forum - 11-09-2010, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB