SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: #1054 - Unknown column 're2.Uname' in 'where clause'

    am trying to get the email of the user from the table re1

    my user details is stored in re1
    re1 has the columns

    id
    fullname,
    username
    password
    email
    code
    activate

    while their orders is stored in re2 table
    re2 has the columns

    id
    Sname
    Pname
    Pidno
    Psize
    Pcolour
    Pquantity
    Weblink
    Price
    date
    Uname


    and their relationship is that Uname is their {session username} in re2table
    which is their username in the re1 table

    i used this query
    Code:
    SELECT email  FROM re1 WHERE re1.username = re2.Uname
    which is not working

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    I don't see the re2 table in that query?

    You'll have to join the two tables if you want to extract info from both of them.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i had this error on mysql
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM reusers,wishlist . WHERE reusers.username = wishlist.Uname LIMIT 0, 30' at line 2

    Code:
    SELECT reusers.username, wishlist.Uname .
     FROM reusers,wishlist .
    	WHERE reusers.username = wishlist.Uname

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    What are those dots?

  5. #5
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i removed the dot, the query worked but return no value

    Code:
    SELECT reusers.username, wishlist.Uname
     FROM reusers,wishlist
    	WHERE reusers.username = wishlist.Uname

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    That means there are no rows in the two tables that satisfy the join condition.
    Did you test the query in phpMyAdmin?

  7. #7
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Phpmyadmin also returned no rows will have a good look at it thanks

  8. #8
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Check the content of the two tables, especially the values of username and Uname.

    And a question: since you have an id column in the users table, why don't you use that as a foreign key in the orders table?

  9. #9
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your data in the tables clean? You haven't introduced hidden characters or spaces or tabs into the data by mistake have you?

  10. #10
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i was selecting the wrong column, i was supposed to be calling for reusers.email

    SELECT reusers.email
    FROM reusers, wishlist
    WHERE reusers.username = wishlist.Uname

    and it worked, thanks guido, and guelphdad


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •