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

Reply via email to