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
SELECT email FROM re1 WHERE re1.username = re2.Uname
which is not working
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.
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
SELECT reusers.username, wishlist.Uname .
FROM reusers,wishlist .
WHERE reusers.username = wishlist.Uname
i removed the dot, the query worked but return no value
SELECT reusers.username, wishlist.Uname
FROM reusers,wishlist
WHERE reusers.username = wishlist.Uname
That means there are no rows in the two tables that satisfy the join condition.
Did you test the query in phpMyAdmin?
Phpmyadmin also returned no rows will have a good look at it thanks
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?
Is your data in the tables clean? You haven’t introduced hidden characters or spaces or tabs into the data by mistake have you?
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