Specialized Search Question

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Anti-Spam Guide
Post Reply
User avatar
CGI1984
Registered User
Posts: 157
Joined: Thu Feb 20, 2020 8:27 am

Specialized Search Question

Post by CGI1984 »

We have a few forums which have a lot of posts and are supposed to be forums which only contain topics with questions. So we want to be sure each subject header in these forums contains a question mark.

Thus, I am wondering if there a way we ca do a search to help reveal any topics in these forums which are missing the question mark in the subject header? I know the indexing usually doesn't allow you to search for a single digit, so I am not sure if this kind of a search is possible to do. Thank you.
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 4668
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Specialized Search Question

Post by HiFiKabin »

What about questions that do not have a question mark

Like that one
KYPREO
Jr. Extension Validator
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: Specialized Search Question

Post by KYPREO »

You can configure Sphinx to index question marks, but it's a lot of work for a simple task.

THEN what you're really asking for is a search for topic titles NOT ending in a question mark. That could be done but would require custom coding of the search function.

You could just run this query against the database:

Code: Select all

SELECT topic_id, topic_title FROM phpbb_topics WHERE topic_title NOT LIKE '%?';
This will find topics where the topic title does not end in a question mark (substitute your database table name prefix if required).
phpBB user since 2002
www.AusRotary.com
User avatar
CGI1984
Registered User
Posts: 157
Joined: Thu Feb 20, 2020 8:27 am

Re: Specialized Search Question

Post by CGI1984 »

Thank you for that. I will give it a try. :)
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51362
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Specialized Search Question

Post by stevemaury »

That gives you posts where "?" appears anywhere. This is more precise and faster:

Code: Select all

SELECT topic_id, topic_title FROM phpbb_topics WHERE RIGHT(topic_title,1) = '?'
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
KYPREO
Jr. Extension Validator
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: Specialized Search Question

Post by KYPREO »

stevemaury wrote:
Sat Feb 29, 2020 8:22 pm
That gives you posts where "?" appears anywhere. This is more precise and faster:

Code: Select all

SELECT topic_id, topic_title FROM phpbb_topics WHERE RIGHT(topic_title,1) = '?'
The OP wanted to find topics that do not end in a question mark. My query does that. You can do it your way of course but it needs to be inverted with a NOT.
phpBB user since 2002
www.AusRotary.com
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51362
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Specialized Search Question

Post by stevemaury »

Thanks. Misread it. Yes, either will work but yours will hit on a "?" anywhere. Here is my corrected query:

Code: Select all

SELECT topic_id, topic_title FROM phpbb_topics WHERE RIGHT(topic_title,1) != '?'
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
User avatar
AmigoJack
Registered User
Posts: 5716
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Specialized Search Question

Post by AmigoJack »

stevemaury wrote:
Sun Mar 01, 2020 9:55 pm
but yours will hit on a "?" anywhere
No, that's wrong on your end, KYPREO got it right right away. Also performing a string operation on every potential match (RIGHT) surely hits more performance than using an operator (LIKE) - how can that be faster for you?

Note that both the string function RIGHT and the operator != might not be supported on all DBMSs, whereas both operators LIKE and <> must be supported on any. We don't know OP's DBMS yet.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51362
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Specialized Search Question

Post by stevemaury »

Yes, in re-reading the OP, he wants all topic titles that do not CONTAIN a "?", although I originally thought he wanted all titles that did not END with a "?", so, yes KYPREO's initial query would work.

And yes, <> is probably preferable to !=. I tend to assume MySQL or MariaDB is being used if the poster does not specify.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
Post Reply

Return to “phpBB Discussion”