Jump to content

Connecting user_id in different tables


Lv-Kris

Recommended Posts

Hello.
I've came across a need to connect my `users` tables `user_id` with the same `user_id` from `user_stuff` table. Ive been reading about InnoDB and is this the case I should use it?
Ive tried the phpMyAdmin function `link tables` but it doesn't seem to work. Well i could write the `user_id` in all the tables needed upon registering, but, as i suppose, it will cause more server workload and loose efficiency.
Thank You for any advice.
Kris
Link to comment
Share on other sites

Lv-Kris you can select from multiple tables almost as if they are one.
[code]
select
  users.user_name,
  user_stuff.stuffis
from
  users,
  user_stuff
where
  user.user_id = user_stuff.user_id
  and user.userid=1
[/code]

shortened by aliases, but the same
[code]
select u.user_name , s.stuffis
from users u , user_stuff s
where u.user_id = s.user_id
and u.user_id =1
[/code]

Joins are great too.
If you want to use joins , the ref page is here
[url=http://dev.mysql.com/doc/refman/5.1/en/join.html]http://dev.mysql.com/doc/refman/5.1/en/join.html[/url]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.