[thelist] MySQL Table fields

rudy r937 at interlog.com
Thu Jan 23 10:11:01 CST 2003

> too many category 's?

you need to qualify the column names using their table names

SELECT ItemSKU, ItemName, ItemDescription
     , ItemCost, Items.Category,
     , ShippingCost, ItemID
  FROM Items
  JOIN category
    ON Items.Category
     = category.Category

thus category.Category is the Category column of the category table (not
that case matters, except in this sentence)

because of this collision of names, some people "type" the names, i.e.
identify the type of object in its name

thus, tblCategory (which to me is ugly, and inconsistent, because you never
colCategoryID, colCategoryName...)

anyhow, say you renamed your category table as categories, there is still
the case of colliding column names

no matter whether it's category or catid or whatever the column is called,
there are pros and cons to using the same name for the foreign key as the
primary key it references, so whatever way you want it, it's up to you  ;o)

if you leave them the same, you code --

    where Items.category = Categories.category

if you rename one of the columns, you would code --

    where itemcategory  = category



More information about the thelist mailing list