Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- join tables?
August 20, 2006, 7:21 am
rate this thread
table one ("users") contains two columns, "user_id", and "user_name"
table two ("spam") contains three columns "msg_id","user_id", and "msg"
basically, i want to retrieve all the "spam" entries, but instead of
displaying the user_id, i want it to show the user_name, from table
one. (using php)
i'm assuming i need to use this JOIN thing, but i've never used it
before. any help?
Re: join tables?
It might work a bit faster as following:
SELECT * FROM spam JOIN users USING (user_id);
You would use LEFT JOIN if you thought that there might be no entries in
the users table matching the user_id given in the spam table. I would
expect in your case that there should be a user in all such cases, so a
simple inner join would be fine. Inner joins often run quicker than
- » background and partial solution of sql-myql mode of Emacs on WinNT
- — Previous thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum