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
https://forums.phpfreaks.com/topic/36205-connecting-user_id-in-different-tables/
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.