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 9140561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:31:57+00:00 2026-06-17T09:31:57+00:00

Im trying to do a select * from x where name LIKE y.I am

  • 0

Im trying to do a select * from x where name LIKE y.I am very familiar with this code which is below.

SELECT * FROM ` arm` WHERE `u_fname` LIKE 'k%'

However, im trying to run this on a sever script and i am un sure where to put the “%” cause it results in errors. This is part of the sever code, this code works as it is with there ‘=’ but errors out when i use LIKE becuase im unsure how to use the “%” here

   elseif(empty($_POST["f_name"]) &&  !empty($_POST["l_name"])) 
{ 

 $l_name=$_POST["l_name"];
$stmt = $this->db->prepare('SELECT id, image, l_name, f_name, status  FROM table1  WHERE l_name =?');
           $stmt->bind_param("s",$l_name);
         $stmt->execute();
         $stmt->bind_result($id,$image,$l_name,$f_name,$status);   

I tried SELECT id, image, l_name, f_name, status FROM table1 WHERE l_name =?% and i have also tried putting $l_name=$_POST[“l_name%”]; but neither of them seem to work.

Thank you for help.

  • 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-17T09:31:58+00:00Added an answer on June 17, 2026 at 9:31 am

    Your code isn’t using ‘LIKE’
    Your code is: SELECT id, image, l_name, f_name, status FROM table1 WHERE l_name =?
    Try

    $stmt = $this->db->prepare('SELECT id, image, l_name, f_name, status  FROM table1
    WHERE l_name LIKE ?'); 
    $stmt->bind_param("s",$l_name.'%');
    

    Or try

    $stmt = $this->db->prepare('SELECT id, image, l_name, f_name, status  FROM table1
    WHERE l_name LIKE CONCAT(?, "%")');
    $stmt->bind_param("s",$l_name);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to select only some fields from my table with code like this
Am trying to write a very simple select statement like below using Linq against
I'm trying to select the text from the name attribute of the anchor element
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to dynamically resolve the value from cursor something like below. create
In PostgreSQL, there is this very useful string_agg function, that allows query like: SELECT
I'm trying to select from table, excluding where id is something, say 7. I
I'm trying to SELECT based on a date in OpenOffice Base: SELECT * FROM
I'm trying to select records with a statement SELECT * FROM A WHERE LEFT(B,
When trying to select fields from a subquery if ANY of the subqueries do

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.