Linking

Discussion in 'MySQL' started by xadet3, Mar 30, 2007.

  1. #1
    I'm pretty new to MySQL+PHP and I was wondering if anyone could help me.

    I have 2 tables called categorys and links.

    In categorys I have:
    id, category, description and links

    In links I have:
    (several others) and category(which is the using the same id as the id in the categorys table)

    How can I match the 2 id's(id from the 'categorys' table and the category(id from the 'links' table) so instead of showing the name as a query of the category field, making it show the name of the category taken from the 'categorys' field.

    I hope it makes sense :p
     
    xadet3, Mar 30, 2007 IP
  2. cpucandy

    cpucandy Peon

    Messages:
    489
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #2
    OK, I believe you want this.

    You have 2 tables:

    Catagories with field names:
    id, category, desc

    Links with field names:
    category, ** other fields

    To bring back all the rows and the category from the categories table:

    select b.desc from links a, categories b where a.category = b.category
     
    cpucandy, Mar 30, 2007 IP