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

  • Home
  • SEARCH
  • 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 6839435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:43:07+00:00 2026-05-26T23:43:07+00:00

Hello dearest community, EDITED This is my solution, based on Devart answer. I slightly

  • 0

Hello dearest community,

EDITED

This is my solution, based on Devart answer. I slightly modify the procedure parameter and also fix some % things..

DELIMITER $$

DROP PROCEDURE IF EXISTS `cosmedicdb`.`proc_searchall` $$
CREATE PROCEDURE `cosmedicdb`.`proc_searchall` (output TEXT, tbl varchar(50), kolom_kriteria VARCHAR(20),
                                               kolom_nilai VARCHAR(20))
BEGIN

  SET @query = CONCAT('SELECT ', output, ' FROM ',tbl,' WHERE ', kolom_kriteria, ' LIKE CONCAT(','\'%',kolom_nilai, '%\')');
  PREPARE stmt FROM @query;
  EXECUTE stmt;
  DEALLOCATE PREPARE stmt;

END $$

DELIMITER ;

I think one can enhance this to support search of numeric value field

Original Question below

First of all, I hope this is not a repost question.
I want to create a flexible search procedure. That is, the column ad the value of the column to be search, can be supplied from the argument itself. Currently this is my search procedure looks like :

DELIMITER $$

DROP PROCEDURE IF EXISTS `cosmedicdb`.`proc_searchtindakan` $$
CREATE PROCEDURE `cosmedicdb`.`proc_searchtindakan` (kolom VARCHAR(20),
                                               kolomnilai VARCHAR(20))

BEGIN
 CASE kolom
 WHEN 'jenis'
         THEN
          SELECT jenis, harga
             FROM cosmedicdb.tb_mastertindakan
          where jenis like concat('%',kolomnilai,'%');
 END CASE;
END $$

DELIMITER ;

You can see that this procedure only work for certain column to be search. Is it possible (and safe) to create just one search procedure that allows me to search using any column as the defining search criteria?

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-05-26T23:43:08+00:00Added an answer on May 26, 2026 at 11:43 pm

    You can do it with a prepared statements: build a query and execute it, e.g. –

    DELIMITER $$
    
    CREATE PROCEDURE proc_searchtindakan(IN kolom VARCHAR(20), IN kolomnilai VARCHAR(20))
    BEGIN
      SET @query = CONCAT('SELECT ', kolom, 'FROM cosmedicdb.tb_mastertindakan WHERE ', kolom, ' LIKE CONCAT(\'%\'', kolomnilai, '\'%\'');
      PREPARE stmt FROM @query;
      EXECUTE stmt;
      DEALLOCATE PREPARE stmt;
    END
    $$
    
    DELIMITER ;
    

    …in example I have removed ‘harga’ field from the list of fields; add it if you need.

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

Sidebar

Related Questions

Hello dearest community, I run into problem of creating an exact MD5 of a
Hello dearest community. I have trouble in the last two days, that I can't
Hello dearest community, I am just a regular use of git in Windows. Now
Hello can anybody solve this please I'm creating the object in the action class
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello, Im working on a solution for Android that will record calls (both out
Hello guys can you please help me with this problem. When a simple image
Hello At my form I create TFrame at runtime. At this frame I create
hello i have tryed a lot of source codes for this but i have
Hello I have a custom control. This custom control has it's DataContext set to

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.