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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:26:50+00:00 2026-05-13T06:26:50+00:00

my code is this, $query = SELECT * FROM `cars` WHERE (color LIKE ‘%.

  • 0

my code is this,

$query = "SELECT * FROM  `cars` WHERE  (color LIKE '%". $key ."%' OR name LIKE '%". $key ."%') AND enabled = 'yes'  ORDER BY  `ID`";

database is like this

ID     color       name        enabled
----  ------     --------     ---------
1       red        red car       yes
2      blue        blue car      yes
3       brown      brown car     yes

r

when i search with the key “red” it returns first field (ID 1) but if i search with “red car” it returns nothing.

how can i search both 2 field ?

thanks

EDIT: i fixed brackets but still i cant get results with more than 1 word keys.

Tried this with no luck

  $query = "SELECT * FROM  `cars` WHERE  (MATCH (color,name) AGAINST ('$key' IN BOOLEAN MODE)) AND enabled = 'yes'  ORDER BY  `ID`";

EDIT 2: Peter is right. There is no problen in query. weird thing is
i use this

$key = $_GET['key'];

if $_GET[‘key’] is more than 1 word, $key is returns empty for a reason.

  • 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-13T06:26:50+00:00Added an answer on May 13, 2026 at 6:26 am

    I can’t duplicate your error. Here’s the steps I took

    New table

    CREATE TABLE  `cars` (
      `ID` int(10) unsigned NOT NULL auto_increment,
      `color` varchar(45) NOT NULL,
      `name` varchar(45) NOT NULL,
      `enabled` varchar(45) NOT NULL,
      PRIMARY KEY  (`ID`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    Then added values

    INSERT INTO `cars` (`ID`, `color`, `name`, `enabled`) VALUES
      (1,'red','red car','yes')
    , (2,'blue','blue car','yes')
    , (3,'brown','brown car','yes');
    

    Then testing the queries

    mysql> SELECT * FROM  `cars`
        ->  WHERE (color LIKE '%red%' OR name LIKE '%red%')
        ->    AND enabled = 'yes'
        ->  ORDER BY  `ID`;
    +----+-------+---------+---------+
    | ID | color | name    | enabled |
    +----+-------+---------+---------+
    |  1 | red   | red car | yes     |
    +----+-------+---------+---------+
    1 row in set (0.00 sec)
    
    mysql> SELECT * FROM  `cars`
        ->  WHERE (color LIKE '%red car%' OR name LIKE '%red car%')
        ->    AND enabled = 'yes'
        ->  ORDER BY  `ID`;
    +----+-------+---------+---------+
    | ID | color | name    | enabled |
    +----+-------+---------+---------+
    |  1 | red   | red car | yes     |
    +----+-------+---------+---------+
    1 row in set (0.00 sec)
    

    Maybe look elsewhere for your error

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

Sidebar

Related Questions

I wanna to have query: Select cars.* from cars where cars.code in ( select
I have this elementary query: SELECT d.description, o.code FROM order_positions AS o LEFT JOIN
Take this query: SELECT * FROM MyTable WHERE MyColumn = 'SomeValue' ORDER BY SomeFakeQualifier.MyColumn
now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =
I've got this query: SELECT PICTURE FROM LOGO WHERE LOGONO = ? (PICTURE is
Code like this often happens: l = [] while foo: # baz l.append(bar) #
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
I have a query that sums and aggregates alot of data something like this:
$getquery = mysql_query(SELECT * FROM it_task ORDER BY task_id DESC); while ($rows = mysql_fetch_array($getquery))
In C++, I code this way: //foo.h class cBar { void foobar(); } //foo.cpp

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.