Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have two tables in my database .tables are studentlogin(id,name,age,address,login_id) and student reg(id,login_id).An id will be generated during the registration that is login_id. I have to display this id into anthore page when i click the button.

What I have tried:

I just connect two tables using join
Posted
Updated 29-Jun-16 20:31pm
Comments
Kats2512 24-Jun-16 2:51am    
You answered your own question in the what have you tried section.
OriginalGriff 24-Jun-16 3:00am    
That doesn't make a lot of sense as stated: you have four ID values:
studentlogin.id, studentlogin.login_id, studentreg.id, and studentreg.loginid
And as a result, there is no direct link between them.
Plus, we have no idea which of the two "loginid" values you want to display, or how they are supposed to be kept together.
Have a think about it for a few minutes, and try describing the actual set of processes that need to happen when a student registers, and what values need to be stored and / or fetched from where.
Then try to explain that to us!
Use the "Improve question" widget to edit your question and provide better information.
Kiran Vaidyanathan 27-Jun-16 4:48am    
I assume you have two tables as follows:

studentlogin with fields : id,name,age,address,login_id
studentreg with fields : id,login_id.

Now there can be a relationship between them only if you have "one" common field in both. Can you answer these questions, in order for me to get a clear idea?

1. Why have you used login_id in both tables?
2. In which table will you actually store the value of login_id? in login table or reg table?
3. How will the login_id value be generated?
4. In which table are you referencing the field login_id as a foreign key?
5. From which table do you want to display the data if the user clicks the button?

Please answer these questions and I might be able to help you out!

- Cheers
Member 12595721 27-Jun-16 5:08am    
Use id as the primary key, or u can add one more value to the table, i.e name and connect that. its better not to use both id and login_id together. Keep one.
Arasappan 28-Jun-16 2:40am    
what are all the things u received when registration..

1 solution

Hi,
this is simple question.

Two Table JOIN In One ID.

Use INNER Join

Like:
C#
studentlogin(id,name,age,address,login_id)

JavaScript
student reg(id,login_id)


SQL
select name,id,age,address,login_id from studentlogin INNER JOIN studentreg AS sr ON studentlogin.id= sr.id
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900