![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Dec 2004
Location: Denver
Posts: 6,559
|
MySQL Update / Join on match
I keep getting stuck trying to figure this one out. I have two tables. One is a list of articles, the other is a list of users.
articles table: userid, name, articletitle, articletext, postdate users table: userid, name The articles table is fully populated except for the name column. So I need to update / join the articles table - name column, with the users table - name column, where the userid from both match. I've tried to find an example online, but they all use the standard t.1 or t.2 generic descriptions for the columns and I can't wrap my head around it without seeing better descriptors prudent to my exact situation (like "name" and "userid" in the example). Like I swear it's (SELECT * FROM table1 as t1 INNER JOIN table2 as t2 ON t2.t1_id = t1.t2_id) or something as I've used it in the past. But when I wrote it down in my notes I didn't provide better descriptors. ![]() ![]() ![]()
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
|
select a.articletitle, a.articletext, a.postdate, b.name from articletable as a, usertable as b where a.userid = b.userid
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
are you trying to SELECT or UPDATE?
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
partners.sexier.com
Industry Role:
Join Date: Jan 2007
Location: San Francisco, CA
Posts: 11,926
|
what is primary key in your tables? userid should be your primary key. try to join on that.
and why using as try after from select * from table 1 inner join table 2 on t1.userid=t2.userid or this will work i think select * from table 1 where userid = (select userid from table2); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Dec 2004
Location: Denver
Posts: 6,559
|
got it using:
UPDATE table_1 AS t1, table_2 AS t2 SET t1.name = t2.name WHERE t1.userid = t2.userid
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
partners.sexier.com
Industry Role:
Join Date: Jan 2007
Location: San Francisco, CA
Posts: 11,926
|
upgrade... yes... i didn`t get you in first...
|
![]() |
![]() ![]() ![]() ![]() ![]() |