SQL UPDATE to find two WHERE's before changing code.

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
M.O.B.
Registered User
Posts: 944
Joined: Tue Jan 04, 2005 1:07 am
Location: San Diego CA USA
Contact:

SQL UPDATE to find two WHERE's before changing code.

Post by M.O.B. »

Sorry if I am posting in the wrong forum. And also sorry for the dumb topic title, just didn't know how to word it correctly... :(

Anyways, what I am trying to do is do a SQL UPDATE where it finds two exact columns data, it then makes the following change.

//my goal is to make a shadow topic sticky

Code: Select all

UPDATE phpbb_topics SET topic_type = 1 WHERE topic_moved_id = 2895 AND forum_id = 19
Please let me know if the above SQL Syntax is correct? If you got questions, please ask. :)

My DB is for a phpBB 3.1.10 site.
Image
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: SQL UPDATE to find two WHERE's before changing code.

Post by Toxyy »

Go to your phpmyadmin to enter a custom query, change UPDATE with SELECT, and delete the SET code, and see if it selects the right values for you.

Fixed by Ger below:

Code: Select all

SELECT * FROM phpbb_topics WHERE topic_moved_id = 2895 AND forum_id = 19
Last edited by Toxyy on Wed Jun 28, 2017 1:01 pm, edited 2 times in total.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: SQL UPDATE to find two WHERE's before changing code.

Post by Ger »

Toxyy wrote: Mon Jun 26, 2017 4:20 pm Go to your phpmyadmin to enter a custom query, change UPDATE with SELECT, and delete the SET code, and see if it selects the right values for you.
When follow that advice to the letter, it would result in:

Code: Select all

SELECT phpbb_topics WHERE topic_moved_id = 2895 AND forum_id = 19
That's not OK, is it?
You should have:

Code: Select all

SELECT * FROM phpbb_topics WHERE topic_moved_id = 2895 AND forum_id = 19
That should show you the right information about the topic you're selecting to update.

Now, @TS: I don't know if a moved topic can be sticky at all, but your query seems valid.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: SQL UPDATE to find two WHERE's before changing code.

Post by Toxyy »

You're right. Thanks.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
Post Reply

Return to “phpBB Custom Coding”