[thelist] Help Combining SQL Results

Jay Turley jayturley at gmail.com
Thu Mar 5 14:58:33 CST 2009


Forgot a tip, so a tip of the olde tip hat:

[tip type="javascript jquery validation radio buttons"]
When validating form elements in javascript, one of the biggest pains
was iterating over radio button sets, trying to figure out if one was
checked or not. With jQuery, this becomes very easy. The expression

$('input[name=myRadioButtons]:checked').val()

Will tell you if one of the radio buttons in the following set are checked:

<input type="radio" name="myRadioButtons" id="button1" value="button1"
/> Button 1
<input type="radio" name="myRadioButtons" id="button2" value="button2"
/> Button 2
<input type="radio" name="myRadioButtons" id="button3" value="button3"
/> Button 3
[/tip]

On Thu, Mar 5, 2009 at 11:49 AM, r937 <rudy at r937.com> wrote:
> first thing i noticed, jay, is that your GROUP BY is invalid
>
> which, since you say the query runs, means that this can only be mysql
>
> here's how you sum them --
>
> SELECT id
>     , value
>     , MAX(c_fk_id) AS idunnowhich
>     , SUM(num_entries) AS total_entries
>  FROM (
>       SELECT a.id
>            , a.value
>            , a.c_fk_id
>            , COUNT(*) AS num_entries
>         FROM A AS a
>       GROUP
>           BY a.id
>            , a.value
>       UNION ALL      -- clearly UNION ALL, not UNION
>       SELECT b.id
>            , b.value
>            , b.c_fk_id
>            , COUNT(*)
>         FROM B AS b
>       GROUP
>           BY b.id
>            , b.value
>       ) AS u
> GROUP
>    BY id
>     , value
>
>
> ;o)
>
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list