72 users online (1 members and 71 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 1
  2. Replies: 0
  3. Replies: 10
  4. Replies: 4
  1. #1
    yahn's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    1

    selecting more then it should

    I have this code

    PHP Code:
    $query "SELECT html_attributes.*
    FROM html_attributes
    ORDER BY attribute_name"

    I don't want to select all the html_attributes. I have a html_values table that has three fields. tag, attribute, and value_name. I want to only select the rows in html_attributes where an html_value.tag = a value and the html_attributes.attribute = the html_values.attribute. When I change it to this

    PHP Code:
    $query "SELECT html_attributes.*
    FROM html_attributes
    WHERE html_tags.tag = 
    $tag_id AND html_attributes.attribute = html_values.attribute
    ORDER BY attribute_name"

    It selects the attribute every time an html_values.attribute eqauls its id. Why is it selecting the attribute more than once?

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: selecting more then it should

    This should work:
    Code:
    $query = "SELECT html_attributes.* 
    FROM html_attributes
    INNER JOIN html_attributes
    ON html_attributes.attribute = html_values.attribute
    WHERE html_values.tag = 'a'
    ORDER BY attribute_name";
    Last edited by vinyl-junkie; 09-11-2005 at 12:40 PM.

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: selecting more then it should

    Welcome both of you

    D
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting



Tags for this Thread