php forum
php mysql forum
php mysql smarty
 
Topic Options
#227977 - 11/19/02 09:34 AM Updating data in one table from another
dimopoulos Offline
Kahuna

Registered: 08/18/02
Posts: 1271
Loc: Vienna, Austria
I know how to do this in MSSQL and it is killing me for not being able to find the solution yet.<br /><br />I created a new table called "inchat". Two fields: C_Username, C_Last.<br /><br />I also added a new field in the w3t_online table called "O_InChat" (VARCHAR(3) DEFAULT 'no').<br /><br />I want to run a query that match the C_Username (from the inchat table) with the O_Username (from the w3t_online table) and update the O_InChat field (in the w3t_Online table) to 'yes' for the matched fields.<br /><br />I came up with this - which doesn't work:<br /><pre><font class="small">code:</font><hr><br />UPDATE inchat <br />INNER JOIN w3t_online <br />ON inchat.C_Username = w3t_online.O_Username <br />SET w3t_online.O_InChat = "yes"<br /></pre><hr><br />:wallbash: :wallbash:<br /><br />I don't know what I'm doing wrong....<br /><br />Thanks in advance<br /><br />Warm regards<br /><br />Nikos
_________________________
Nikos

Top
#227978 - 11/19/02 12:26 PM Re: Updating data in one table from another [Re: Hal_dup2]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Hmmm ... I couldn't find any way to do that either, using only a MySQL query.<br /><br />Of course, using PHP, you can first do a select query to get the usernames that match across the inchat and w3t_Online tables, and then do the update query on the w3t_Online table using the result from the first query. I could post some code if you want.<br /><br />Maybe someone else knows a way to do this with a single query.


Edited by Dave_L (11/19/02 01:24 PM)
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top


Who's Online
0 registered (), 25 Guests and 15 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Forum 'Trader Ratings'.
by blaaskaak
11/20/08 08:27 AM
Problems reading a lot of old posts here
by Ruben Rocha
11/18/08 04:33 PM
PhotoPost BB Code Popup
by Iann128
11/15/08 01:24 PM
Customization needed
by Gizmo
11/12/08 12:28 PM
Team UBBDev Rides Again!
by AllenAyres
11/11/08 02:16 PM
Active Topics.
by AllenAyres
11/11/08 02:13 PM
Looking for a simple upload script
by AllenAyres
11/11/08 02:12 PM
New Mods
Forum 'Trader Ratings'.
by McLemore
11/19/08 02:14 PM
[7.4] Keep log of custom title changes
by blaaskaak
10/27/08 07:51 AM
User Authentication Class
by
01/19/07 02:59 PM
Multiple Identity Detector
by
12/30/06 06:39 PM
PhotoPost BB Code Popup
by
11/06/06 05:43 PM
Newest Members
nick1, Begbie, cenk, MATTO, DougMMcts
13362 Registered Users
Top Posters
AllenAyres 25448
JoshPet 11330
Rick 8372
LK 7396
Lord Dexter 6503
Greg Hard 5533
Charles Capps 5438

 

 

 
fusionbb message board php hacks