Mif.ComicVN
Mif.ComicVN

Reputation: 87

Select SQL With 2 table

I have 2 table

User
Colum : User_id,user_name,email

User_Authenticate 
Colum : user_id,user_key,hash

Can i ask for query to get data form 2 table by 1 query with the value is email or user name?

Thanks all

Upvotes: 0

Views: 96

Answers (3)

Ahmed Jolani
Ahmed Jolani

Reputation: 3102

The result will output user's info as this:

email  user_name  user_key  hash
-----  ---------  --------  ----
[email protected]   xxxx       xxxx     xxxx

Of course the result will be related to the other table User_Authenticate.
SQL Query:

SELECT email, user_name, user_key, hash FROM User JOIN User_Authenticate ON User.User_id = User_Authenticate.user_id AND email='EMAIL-ENTERED' AND user_name='USERNAME-ENTERED'



Enjoy! And next time please search Google before you ask a question no need for redundancy!

Upvotes: 1

Taryn
Taryn

Reputation: 247880

SELECT *
FROM User u
JOIN User_Authenticate ua
    on u.User_id = ua.user_id 
WHERE u.user_name = 'yourusername'
    OR u.email = '[email protected]'

Upvotes: 1

Dennis Hunink
Dennis Hunink

Reputation: 583

SELECT * FROM user JOIN User_authenticate ON User.user_id=user_authenticate.user_id WHERE user.email = $something

Just a very scratch try, should give you some hints..

Upvotes: 0

Related Questions