Tuesday 10 September 2013

Need help grabbing all the data from two tables in SQL

Need help grabbing all the data from two tables in SQL

I have a form set up where the user can enter in the username or lastname
of a person. I then take either the username or lastname depending on what
they entered and query the database and displaying all the userinformation
and whether they have access to certain areas. There are two tables I need
to query and get all the information for the user entered. I'm assuming
you use a JOIN but I'm not quite sure how to do it. Right now I have the
query to grab all the data from the users table I just need help adding in
the second table. The two tables look like this
Users { uid username password firstname lastname email }
userAccess { uid assessment development learningmodule project }
The SQL I have so far is
SELECT *
FROM Users
WHERE username = '$username' OR lastname = '$lastname'

No comments:

Post a Comment