Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:03:10+00:00 2026-06-07T13:03:10+00:00

I have a query that goes something like this: SELECT t1, t2, IF(MATCH(t2) AGAINST

  • 0

I have a query that goes something like this:

SELECT t1, t2,
IF(MATCH(t2) AGAINST ('input*' IN BOOLEAN MODE), 10, 0) AS matches,
IF(t2 LIKE '%input%', 2, 0) AS similar
FROM tbl
WHERE t2 LIKE '%input%'
ORDER BY (matches + similar) DESC
LIMIT 5

The query works fine, but the part I’m concerned about is whether or not MySQL is checking whether t2 is LIKE ‘%input%’ twice, or if it caches the first result (which would be cool!).

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:03:11+00:00Added an answer on June 7, 2026 at 1:03 pm

    Sorry, it does not.

    As a poor man’s test, consider:

    delimiter //
    create function qqq() 
    returns int no sql 
    begin 
      set @x:=@x+1; 
      return 17; 
    end //
    delimiter ;
    
    set @x := 0;
    select qqq(), qqq(), qqq() > 1, qqq() > 1 from dual;
    +-------+-------+-----------+-----------+
    | qqq() | qqq() | qqq() > 1 | qqq() > 1 |
    +-------+-------+-----------+-----------+
    |    17 |    17 |         1 |         1 |
    +-------+-------+-----------+-----------+
    
    select @x;
    +------+
    | @x   |
    +------+
    |    4 |
    +------+
    

    While one can argue that this is a special case, since we’re invoking a stored routine, as opposed to built-in function, there is no difference at the moment. Everything is re-evaluated.

    This may change in the future — there’s nothing to strictly prevent this optimization from happening on well known, deterministic functions. But sometimes this may be hard to diagnose by the optimizer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query that (stripped right down) goes something like this : SELECT
i have a query that goes like this: SELECT * FROM table_a LEFT JOIN
i have a query that goes like this: $get_feed_amount = mysql_query( SELECT COUNT(*) as
I have a query that goes something like this : ;WITH t as (
I have a query that looks like this SELECT * from myTable WHERE Date
I have a stored procedure that goes something like this (pseudo code) storedprocedure param1,
I have a query which goes like this. SELECT * FROM <database1> WHERE (Condition1)
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,
I have a query that creates a result set like this: Rank Name 1
I have a table that looks something like this: CREATE TABLE student_results(id integer, name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.