Odd Update Question.

2008-02-27 Thread m i l e s
Hi, I'm wondering if the following can be done UPDATE tbe_gallery SET tbe_gsa.gsa_paperprice = tbe_gallery.gallery_gsaprice_paper WHERE tbe_gallery.gallery_id = tbe_images.img_rel_id AND tbe_images.img_orig_filename = tbe_gsa.gsa_id Let me explain: I have 3 tables and only 1 of them

weird select - version 2

2008-02-27 Thread dante
Hi, Dont know if my last post got to the list, but since then my problem got a bit more complicated. I know how to solve it using two or more queries, but was wondering if it would be possible using only one: tableA id_tA numof descr 1 0809 john 2 0808 peter table_out id_tOut

Re: joining and grouping

2008-02-27 Thread Phil
Ok then, so select candidate,count(*) as total from vote where (voter <> '$me' and vote =1) group by candidate order by total desc; On Wed, Feb 27, 2008 at 9:37 AM, Olav Mørkrid <[EMAIL PROTECTED]> wrote: > hi phil, i forgot to mention one thing. > > the table also has a column called "vote" w

Re: recursion

2008-02-27 Thread Paul DuBois
At 7:27 AM + 2/27/08, Thufir wrote: I'm reading "SQL for dummies" and one of the more interesting sections was on recursion. The example query was something like: WITH RECURSIVE ReachableFrom (Source, Destination) AS (SELECT Source, Destination FROM FLIGHT UNION SELECT in.

Re: joining and grouping

2008-02-27 Thread Olav Mørkrid
hi phil, i forgot to mention one thing. the table also has a column called "vote" which is either 0 (no vote given) or 1 (vote given). this column is required for other purposes. my favorites: select candidate from vote where voter = '$me' and vote = 1; most popular: select candidate from vote w

RE: recursion

2008-02-27 Thread emierzwa
I'm not aware of MySQL supporting this feature. Microsoft does and calls it "common table expression" (CTE). The UNION is necessary as this the part that links the anchor query, Part1 of the UNION to the recursive query, Part2. Part2 of the UNION must reference the produced temporary table called "

Re: joining and grouping

2008-02-27 Thread Phil
I'm confused as to why you need the subselect at all? As it's all the same table why can't you just use select candidate,count(*) as total from vote where voter <> '$me' group by candidate order by total desc; On Wed, Feb 27, 2008 at 9:04 AM, Olav Mørkrid <[EMAIL PROTECTED]> wrote: > hello >

joining and grouping

2008-02-27 Thread Olav Mørkrid
hello i have a table "vote" which has the columns "voter" and "candidate". i would like to make a list of the most popular candidates *except* those who are on my favorite list. using a sub-select, it's easy: my favorites: select candidate from vote where voter = '$me'; most popular: select cand

Re: Insert...on duplicate with aggregate

2008-02-27 Thread Phil
Awesome! Thanks Baron, works perfectly.. Phil On Tue, Feb 26, 2008 at 10:06 PM, Baron Schwartz <[EMAIL PROTECTED]> wrote: > Hi! > > On Tue, Feb 26, 2008 at 7:04 PM, Phil <[EMAIL PROTECTED]> wrote: > > I have a table countrystats defined as > > > > CREATE TABLE IF NOT EXISTS `countrystats` ( >