OK hey guys, I have a table in mysql called topics with userid and topicid.
I want to be able to modify a table called users, but i want to select the userid from the topics table where the topicid = 123.
How would I be able to "SELECT userid FROM topics WHERE topicid = ‘123’ "
Store the userid in a variable.
Then "MODIFY users (rank) VALUES (‘Recruit’) WHERE userid = $variable (EG: 123) "
Sorry, its late and I know the post is completed.
r937
2
INSERT
INTO phpbb_user_group
( group_id
, user_id )
SELECT 28
, userid
FROM topics
WHERE topicid = 123
look ma, no variables

IBazz
4
will topic to user always be a 1:1 relationship? If there may be two users for the one topic, your suggested query won’t do.
So you’ll need to follow my previous post. As to storing a variable for user_id, that’s a php issue, not MySQL.
bazz
Im currently modding my phpbb.
I have a topic table, with userid, witch is the author of the topic, not the posts.
INSERT INTO phpbb_user_group (group_id
, user_id
) VALUES (‘28’, ‘USERID’);
That is the INSERT, all I need to do is some how replace USERID with something like this:
( SELECT userid
FROM topics
WHERE topicid = 123 )
Just like you did above.
IBazz
6
You’ll need the user_id before running the insert statement, I think
bazz
[MYSQL]
UPDATE users
SET rank = ‘Recruit’
WHERE userid =
( SELECT userid
FROM topics
WHERE topicid = 123 )[/MYSQL]
That works perfectly, but I need the same for an Insert.
If not, How can I store the userid in a variable, so i can use use WHERE userid = $userid
r937
8
UPDATE users
SET rank = 'Recruit'
WHERE userid =
( SELECT userid
FROM topics
WHERE topicid = 123 )
look ma, no variable

How would I go about doing this in an Insert?
INSERT INTO phpbb_user_group (group_id
, user_id
) VALUES (‘28’, ‘USERID’);
Where it says userID, i need something like this code that works:
( SELECT topic_poster
FROM phpbb_topics
WHERE topic_id = 231 )
r937
11
there is no MODIFY statement
what were you trying to do with it?
Wow that easy, thank you <3
Sorry! Please move this to mysql forum.