Matar Posted August 27, 2006 Share Posted August 27, 2006 hi how i can retreve a data form two related tables ?i have 2 tables 1 - users table : this table contains the username and password for the users 2 - data table : this table conatins an addtional data about the user .so how i can make a connection to the user table after that the script dedected the data from the data table ??? Link to comment Share on other sites More sharing options...
lordfa9 Posted August 28, 2006 Share Posted August 28, 2006 hmm i tried using inner join once for my SQL statement once but it didn't really work.Maybe you are better off combining the two tables together? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2006 Share Posted August 28, 2006 You can use a join. Say you have users table, that has a userID field, and the data table also has a userID field. You can do something like this:SELECT * FROM users, data WHERE users.userID='someuser' and users.userID=data.userIDIf the tables have fields with the same name, you will need to do some more specifying (instead of SELECT *) to get the fields you want, and maybe get them with unique names. Like this:SELECT users.field1 as userfield1, data.field1 as datafield1 ...etc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now