Jump to content

i have a problem


Matar

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...