Gabriel. This works fine and the two tables talk to each other.
BUT, My website can have 5 - 10 news stories per month. So in the tblNews I could have nMonth t1 t2 2 I am a line This is one, too. 2 Another headline different story 2 Another headline different story 2 Another headline different story 3 Another headline different story 3 Another headline different story 4 Another headline different story 4 Another headline different story 4 Another headline different story 5 Another headline different story 5 Another headline different story 5 Another headline different story I need to use DISTINCT in the SQL lingo as I "bind" the recordset's "nMonth" to a dropdown list. I only require one instance of each "nMonth". So that a visitor can select a month from a drop down and past the months name into a detail page that shows all records. For example a visitor will click on February and be taken to a page that shows 4 records from above table. I have performed a similar fuction on this site: http://www.norfolk.gov.uk/jubilee/ with towns. Towns are easy because they can be stored alphabetically, months need to retain their chronological order. +--------+----------------------------------+-------------------+ | nMonth | t1 | t2 | +--------+----------------------------------+-------------------+ | 2 | | | | 6 | These are other lines | foo lines | | 12 | All your lines are belong to us. | Are not. | +--------+----------------------------------+-------------------+ -----Original Message----- From: Peter Sampson [mailto:[EMAIL PROTECTED]] Sent: 16 May 2002 06:58 To: Sampson, Peter Subject: Fw: Fw: Simple SQL ----- Original Message ----- From: Gabriel <> To: Peter Sampson <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, May 15, 2002 10:29 PM Subject: Re: Fw: Simple SQL > This was addressed privately, but that's not a big deal. :) (I forgot > to hit reply-all. :P) > > Peter Sampson wrote: > > So i change the properties of Month to Integer in tblNews? > > Say you have two tables: > > mysql> show tables; > +----------------+ > | Tables_in_test | > +----------------+ > | MonthNames | > | tblNews | > +----------------+ > 2 rows in set (0.00 sec) > > MonthNames contains two fields: nMonth and mName. tblNews (for this > example, anyway) contains three fields: nMonth, t1, and t2. > > tblNews is populated with whatever, and numbers in the nMonth field that > coorespond to the nMonth in MonthNames. > > This can be obtained with a join: > > SELECT mn.mName, n.t1, n.t2 FROM tblNews n LEFT JOIN MonthNames mn > ON n.nMonth = mn.nMonth ; > > > I can populate the MonthNames table with jan feb march etc.... > > > > Please can you clarify the next bit, I not familar with n JOIN .... ON n > > Month? > > The "FROM tblNews n" and "JOIN MonthNames mn" parts alias those tables > to aliased names (tblNews is aliased to n, and MonthNames is aliased to > mn). This is wholy irrelevent, and is just helpful for typing less > stuff. :) > > Say we populate MonthNames with these values: > mysql> select * from MonthNames; > +--------+-------+ > | nMonth | mName | > +--------+-------+ > | 1 | Jan | > | 2 | Feb | > | 3 | Mar | > | 4 | Apr | > | 5 | May | > | 6 | Jun | > | 7 | Jul | > | 8 | Aug | > | 9 | Sep | > | 10 | Oct | > | 11 | Nov | > | 12 | Dec | > +--------+-------+ > 12 rows in set (0.00 sec) > > And tblNews with this: > mysql> select * from tblNews; > +--------+----------------------------------+-------------------+ > | nMonth | t1 | t2 | > +--------+----------------------------------+-------------------+ > | 2 | I am a line | This is one, too. | > | 6 | These are other lines | foo lines | > | 12 | All your lines are belong to us. | Are not. | > +--------+----------------------------------+-------------------+ > 3 rows in set (0.00 sec) > > And we can then perform a join on that to give us a query with month > names that can be sorted by month name, or whatever. > > mysql> SELECT mn.mName, n.t1, n.t2 FROM tblNews n LEFT JOIN MonthNames > mn ON n.nMonth = mn.nMonth ORDER BY n.nMonth ; > +-------+----------------------------------+-------------------+ > | mName | t1 | t2 | > +-------+----------------------------------+-------------------+ > | Feb | I am a line | This is one, too. | > | Jun | These are other lines | foo lines | > | Dec | All your lines are belong to us. | Are not. | > +-------+----------------------------------+-------------------+ > 3 rows in set (0.03 sec) > > > Does this help? > > -- > Gabriel Cain > Unix Systems Administrator [EMAIL PROTECTED] > Dialup USA, Inc. 888-460-2286 ext 208 > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > The information contained in this email is intended only for the person or organization to which it is addressed. If you have received it by mistake, please disregard and notify the sender immediately. Unauthorized disclosure or use of such information may be a breach of legislation or confidentiality and may be legally privileged. Emails sent from and received by Members and employees of Norfolk County Council may be monitored. Unless this email relates to Norfolk County Council business it will be regarded by the Council as personal and will not be authorized by or sent on behalf of the Council. The sender will have sole responsibility for any legal actions or disputes that may arise. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php