Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Field Linking
03-30-2009, 12:20 AM #1
- Join Date
- Mar 2009
- Thanked 3 Times in 3 Posts
Awright, there's this table called 'users':
Ok, now, there's the table 'news':
What I'd like to do is to link this 'user_id' with the 'user_id' from the other table. What's the best method for doing this?
03-30-2009, 03:21 AM #2
Depends on what you want to do with the result.
If all you want to do is get all the related fields from both tables:
SELECT U.user_id, U.name, U.`password`,N.news_id,N.news FROM `users` AS U, news AS N WHERE U.user_id = N.user_id ORDER BY U.name, N.news_id
SELECT U.user_id, U.name, U.`password`,N.news_id,N.news FROM `users` AS U LEFT JOIN news AS N ON U.user_id = N.user_id ORDER BY U.name, N.news_id