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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-28-2010, 12:31 PM   #1
potter
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.

__________________

potter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-28-2010, 12:39 PM   #2
tical
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

Last edited by tical; 12-28-2010 at 12:40 PM..
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-28-2010, 12:47 PM   #3
woj
<&(©¿©)&>
 
woj's Avatar
 
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
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-28-2010, 12:48 PM   #4
bbobby86
partners.sexier.com
 
bbobby86's Avatar
 
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);
__________________

bbobby86 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-28-2010, 01:06 PM   #5
potter
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
__________________

potter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-28-2010, 01:11 PM   #6
bbobby86
partners.sexier.com
 
bbobby86's Avatar
 
Industry Role:
Join Date: Jan 2007
Location: San Francisco, CA
Posts: 11,926
upgrade... yes... i didn`t get you in first...
__________________

bbobby86 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.