Thread: SQL Book
Hi everyone- I'm a newbie at PostgreSQL and wanted to learn more about postgres. What would be a good book to read up on for learning postgreSQL or SQL in general. Amazon refers me: The Essence of SQL : "A Guide to Learning Most of SQL in the Least Amount of Time ~ Usually ships in 24 hours David Rozenshtein, Tom Bondur (Editor) / Paperback / Published 1998 " __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com
newbie,hmm, the first homework is: find the answer in the archive of this list! hint: search for book. actually you can also find it in the "official" online doc. On Mon, 31 Jan 2000, Peter Landis wrote: > Hi everyone- > I'm a newbie at PostgreSQL and wanted to learn > more about postgres. What would be a good book to > read up on for learning postgreSQL or SQL in general. > Amazon refers me: > The Essence of SQL : "A Guide to Learning Most of SQL > in the Least Amount of Time ~ Usually ships in 24 > hours > David Rozenshtein, Tom Bondur (Editor) / Paperback / > Published 1998 " > > __________________________________________________ > Do You Yahoo!? > Talk to your friends online with Yahoo! Messenger. > http://im.yahoo.com > > ************ >
From: <kaiq@realtyideas.com> > newbie,hmm, the first homework is: find the answer in > the archive of this list! hint: search for book. > actually you can also find it in the "official" online > doc. > Depending on where you start from, make sure you know some basic database design as well as the SQL. I spent 3 tedious years studying various db courses and can boil it down into 3 laws: 1. Always put one value into one field. 2. Never store the same value twice. 3. Always make sure every record has a unique key. Of course, you can always break these laws when you feel like it, but don't start complaining if you get slapped in irons... SQL is just a matter of learning syntax - you can always keep the book/help/webpage next to you for that. The book being mentioned might teach you a few more specific tricks, but the principles hold whatever system you're using. tip - if you're coming from microsoft, build some test queries using MS Access grid queries then look at the SQL view. Not standard SQL of course - microsoft's version, but it'll give you an idea. Apologies if you know all about DB design and just wanted to know about SQL, but I know too many people who've launched into building an Access database worrying about VBA syntax rather than whether their underlying tables were sound or not. -- Richard Huxton Archonet Ltd.
> Hi everyone- > I'm a newbie at PostgreSQL and wanted to learn > more about postgres. What would be a good book to > read up on for learning postgreSQL or SQL in general. > Amazon refers me: > The Essence of SQL : "A Guide to Learning Most of SQL > in the Least Amount of Time ~ Usually ships in 24 > hours > David Rozenshtein, Tom Bondur (Editor) / Paperback / > Published 1998 " Read my book on the web site under documentation. -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Hi, I am running this query and expecting distinct results ebmh=> SELECT DISTINCT articles.id FROM articles, paragraphs WHERE paragraphs.ar ticle_key = articles.id and paragraphs.paragraph ~* 'dementia' ORDER BY articles .page_no; id -- 4 4 4 4 16 12 12 12 12 12 3 3 3 (13 rows) however, if i remove the ORDER BY, it works ebmh=> SELECT DISTINCT articles.id FROM articles, paragraphs WHERE paragraphs.ar ticle_key = articles.id and paragraphs.paragraph ~* 'dementia'; id -- 3 4 12 16 (4 rows) this is in 6.4 and 6.5.2, am i doing something wrong? Cheers Tim Joyce Chief Enthusiast tim@hoop.co.uk HOOP Ltd http://www.hoop.co.uk 01202 251 816 HOOP is proud to be a member of the Paneris community (www.paneris.co.uk)
I think the source of the problem here is that the field you're using to order by (page_no) is not actually an output field of the query. I'm guessing that, when it finds the reference to page_no, the parser is implicitly deciding it has to replace the "DISTINCT articles.id" with "DISTINCT *" if it is to have any chance at doing the required sorting. Personally, this interpretation doesn't really make sense to me (I'd have thought it should trigger a syntax error). Anyway, back to getting a sensible answer from your query. As it stands, I think the query is ambiguous. If 'dementia' appears on a number of pages in a given article, how do you want the results to be ordered? The two main choices seem to be: 1. Simply order by article id number, in which case substituting "ORDER BY articles.id" in the original query will suffice. 2. Order by page number of first appearance (say), in which case a query like this should work: SELECT articles.id, MIN(articles.page_no) AS page_no FROM articles, paragraphs WHERE paragraphs.article_key = articles.id and paragraphs.paragraph ~* 'dementia' GROUP BY articles.id ORDER BY MIN(articles.page_no); Hope that helps. Sean. > -----Original Message----- > From: Behalf Of Tim Joyce > Sent: Tuesday, 1 February 2000 6:44 > To: PGSQL > Subject: [GENERAL] select distinct > > > Hi, > > I am running this query and expecting distinct results > > ebmh=> SELECT DISTINCT articles.id FROM articles, paragraphs WHERE > paragraphs.ar > ticle_key = articles.id and paragraphs.paragraph ~* 'dementia' ORDER BY > articles > .page_no; > id > -- > 4 > 4 > 4 > 4 > 16 > 12 > 12 > 12 > 12 > 12 > 3 > 3 > 3 > (13 rows) > > however, if i remove the ORDER BY, it works > > ebmh=> SELECT DISTINCT articles.id FROM articles, paragraphs WHERE > paragraphs.ar > ticle_key = articles.id and paragraphs.paragraph ~* 'dementia'; > id > -- > 3 > 4 > 12 > 16 > (4 rows) > > this is in 6.4 and 6.5.2, am i doing something wrong? > > Cheers > > Tim Joyce > Chief Enthusiast > tim@hoop.co.uk > HOOP Ltd > http://www.hoop.co.uk > 01202 251 816 > > HOOP is proud to be a member of the Paneris community (www.paneris.co.uk) > > > > > > ************ > >