Using 2 tables
Moderator: General Moderators
Using 2 tables
In my db i have 2 tables: 1 - log in, 2 - other information.
The user will log in and add information on the second table.
My question is: how will i select from second table the information only for the log in user?
The user will log in and add information on the second table.
My question is: how will i select from second table the information only for the log in user?
Re: Using 2 tables
You'll need a relationship between the primary key in the user's table, and the "other information table" so you can know who to get information for.
Does that make sense?
Does that make sense?
Re: Using 2 tables
jackpf wrote:You'll need a relationship between the primary key in the user's table, and the "other information table" so you can know who to get information for.
Does that make sense?
From the second table i show get just the id?
Re: Using 2 tables
You'll need a field in the second table to store the ID or whatever the primary key is for the first table in, so that you know whose data it is.
Re: Using 2 tables
table 1:
id_table1
user
pass
table 2:
id_table2
information
This is my db.
Can u pls give me an example? I can understand faster and better.
id_table1
user
pass
table 2:
id_table2
information
This is my db.
Can u pls give me an example? I can understand faster and better.
-
ronnietherocket
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 20, 2009 11:38 am
Re: Using 2 tables
table 1:
id_table1<-this should be the primary key for tbl1
user
pass
table 2:
id_table2<-this should be the primary key for tbl2
id_table1
information
id_table1<-this should be the primary key for tbl1
user
pass
table 2:
id_table2<-this should be the primary key for tbl2
id_table1
information
Re: Using 2 tables
they are primary key but relationship between the primary key in the user's table and the id_table2 so you can know who to get information for. how im doing this?
Re: Using 2 tables
No, id_table1 in table 2 should contain the id_table1 from table 1.
-
straightman
- Forum Commoner
- Posts: 48
- Joined: Sun Apr 19, 2009 5:20 am
Re: Using 2 tables
well, include in the WHERE clause the ID of the logged in user
===========================================================================================
===========================================================================================
cronika wrote:In my db i have 2 tables: 1 - log in, 2 - other information.
The user will log in and add information on the second table.
My question is: how will i select from second table the information only for the log in user?
-
straightman
- Forum Commoner
- Posts: 48
- Joined: Sun Apr 19, 2009 5:20 am
Re: Using 2 tables
I think what our Romanian guy wants is the query basically
SELECT * FROM informationtable
WHERE logintable.id = informationtable.id;
i have to think that you have linked the tables properly by setting the relationships. Where is your sql code?
Alvaro
===================================================================================
SELECT * FROM informationtable
WHERE logintable.id = informationtable.id;
i have to think that you have linked the tables properly by setting the relationships. Where is your sql code?
Alvaro
===================================================================================
straightman wrote:well, include in the WHERE clause the ID of the logged in user
===========================================================================================
cronika wrote:In my db i have 2 tables: 1 - log in, 2 - other information.
The user will log in and add information on the second table.
My question is: how will i select from second table the information only for the log in user?