Re: Query Help

From: Joe Koenig <joe(at)jwebmedia(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Query Help
Date: 2001-12-17 20:33:26
Message-ID: 3C1E5695.98B1EC4F@jwebmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the responses - I was able to patch something together from
the responses. On to the next thing - I want to do a search based on a
reg ex. Does PostgreSQL have something like MySQL's "RLIKE"? I want to
pull all records in a category that start with a number 0-9. The best
way I saw was to do a UNION with all the numbers, but I figured there
was a better way. Thanks,

Joe

Chris Albertson wrote:
>
> Try this:
>
> 1) Remove DISTINCT ON(item.description)
> 2) Add "GROUP BY item.description"
> 3) Add (after SELECT) "count(pack_num),"
>
> --- Joe Koenig <joe(at)jwebmedia(dot)com> wrote:
> > I have an existing query to pull some product info from my db - there
> > is
> > a field, item.pack_num, that tells whether the item is new (1) or
> > used
> > (2). When I display the listing to the web users, I want to be able
> > to
> > tell them if a used item is available for each item in the list.
> > However, I want this to all be done with 1 query - so what I'm
> > wondering
> > is, is there a way to modify my exising query (below) to have it give
> > the the item with the pack_num of 2, if there are new and used items
> > in
> > the db. The DISTINCT ON(item.description) is there because if there
> > is a
> > new and used item, the item is listed in the db twice, once for each
> > pack_num (I know, bad layout - not my idea...). I don't want the
> > query
> <SNIP>
>
> =====
> Chris Albertson
> Home: 310-376-1029 chrisalbertson90278(at)yahoo(dot)com
> Cell: 310-990-7550
> Office: 310-336-5189 Christopher(dot)J(dot)Albertson(at)aero(dot)org
>
> __________________________________________________
> Do You Yahoo!?
> Check out Yahoo! Shopping and Yahoo! Auctions for all of
> your unique holiday gifts! Buy at http://shopping.yahoo.com
> or bid at http://auctions.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2001-12-17 21:10:13 Re: Query Help
Previous Message Trond Eivind Glomsrød 2001-12-17 19:06:26 Re: Pl/Tcl problem