INSERT INTO table2 (columnName2) SELECT column1 FROM table1
INSERT INTO table2 (columnName2, userid) SELECT column1, userid FROM table1 WHERE userid = 3736
UPDATE table1 SET column2 = column1
UPDATE table1 SET column2 = column1 WHERE userid = 3736
I'm going to give this a try, thanks againYeah, it's totally possible.
INSERT into table2 from table1, for all users
SQL:INSERT INTO table2 (columnName2) SELECT column1 FROM table1
INSERT into table2 from table1, for a single user
SQL:INSERT INTO table2 (columnName2, userid) SELECT column1, userid FROM table1 WHERE userid = 3736
UPDATE table1 column2 with the value from table1's column1, for all users
SQL:UPDATE table1 SET column2 = column1
for a single user
SQL:UPDATE table1 SET column2 = column1 WHERE userid = 3736
Just curious is possible to update a table based off a condition? So if user id on table 1 matches user id on table 2 update value credits. if that makes sense?
UPDATE table2 SET credits = 1 WHERE userid IN (SELECT userid FROM table2) AND userid = 3637
UPDATE table2 SET credits = credits + (SELECT count(id) FROM table1 WHERE userid = 3736) WHERE userid = 3736
UPDATE user_credits SET credits = credits + (SELECT count(id) FROM user_posts WHERE userid = 3736)*3 WHERE userid = 3736
UPDATE user_credits SET credits = credits + ((SELECT count(id) FROM user_posts WHERE userid = 3736)*3) + ((SELECT count(id) FROM user_threads WHERE userid= 3736)*6) WHERE userid = 3736
UPDATE user_credits SET credits = credits + ((SELECT count(id) FROM user_posts WHERE userid = 3736 AND credits_awarded = 0)*3) + ((SELECT count(id) FROM user_threads WHERE userid= 3736 AND credits_awarded = 0)*6) WHERE userid = 3736
Yeah give it a go! You could also add more WHERE statements to award credits for specific forum sections instead of all forum sectionsI’m at work now but I’ll give this a try when I get home!
Awesome, I appreciate this a lot!Yeah give it a go! You could also add more WHERE statements to award credits for specific forum sections instead of all forum sections
For example you could say...
WHERE userid = 1 AND credits_awarded = 0 AND forum_id !=5
That would exclude all posts in forum id 5 - example: forum games section
Awesome, I appreciate this a lot!
What does Where mean?
We use essential cookies to make this site work, and optional cookies to enhance your experience.