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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:23:52+00:00 2026-06-10T19:23:52+00:00

Q: How can i make mysql query search in multiple rows What i want

  • 0

Q: How can i make mysql query search in multiple rows

What i want to make script search is:

if kat_preces_params.params_id is equal to 124 AND kat_preces_params.nosaukums is  LIKE '%$make%',

AND if kat_preces_params.params_id is equal to 125 AND kat_preces_params.nosaukums is LIKE '%$model%' 

AND IF kat_preces_params.params_id is equal to 126 AND kat_preces_params.nosaukums <=2009 AND kat_preces_params.nosaukums >=2000

How i tried to do it (i know it’s wrong, ’cause it doesn’t display right values…):

PHP checking the year:

if($year == '2010 - ...'){
    $gads = 'kat_preces_params.nosaukums <=2010';
}
elseif($year == '2000 - 2009'){
    $gads = 'kat_preces_params.nosaukums <=2009 AND kat_preces_params.nosaukums >=2000';
}
elseif($year == '2000 - 2004'){
    $gads = "kat_preces_params.nosaukums <=2004 AND kat_preces_params.nosaukums >= 2000";
}
elseif($year == '... - 1999'){
    $gads = "kat_preces_params.nosaukums <=1991";

}

AND I have a mysql query looking like this:

SELECT kat_prece.*, kat_preces_params.* FROM kat_prece, kat_preces_params WHERE pamat_kat_sad = '$cat_mod_id' 
AND kat_prece.preces_id = kat_preces_params.preces_id 
AND ((
    kat_preces_params.params_id=124 
    AND kat_preces_params.nosaukums LIKE '%$make%'
    ) 
    || (
        kat_preces_params.params_id=125 
        AND kat_preces_params.nosaukums LIKE '%$model%'
        ) 
    AND kat_preces_params.params_id=126 
    AND $gads
    )

$model and $make are requested values

Maybe it’s possible with INNER JOIN or somehow (don’t know nothing about inner join)?

THANK YOU!

  • 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-10T19:23:54+00:00Added an answer on June 10, 2026 at 7:23 pm
    • Change the $gads definition to this: kat_preces_params.nosaukums BETWEEN 2000 AND 2009 and so on.
    • From your first set of prerequisites, I think what you need is something like: kat_preces_params.params_id IN (124, 125, 126) AND kat_preces_params.nosaukums LIKE '%$make%' OR kat_preces_params.nosaukums LIKE '%$model%'.

    What I don’t understand is that what type of data is there in kat_preces_params.nosaukums where you are once comparing them as INTEGER and another time, as STRINGS.

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

Sidebar

Related Questions

How can I make a mysql dump for table from a query? I need
I've been trying to figure out how I can make a query with MySQL
I want to make a mysql union search. My purpose is: my total results
I am a beginner in Mysql Php. I want to make a search box
I'm trying to make a search in a table, something like this: http://www.phpjabbers.com/free-scripts/mysql-search-table/search.php I
I'm trying to figue out how to make my search.php script work with mySQL.
How can i make mysql start every time the system boot ? I need
How can I make an average between dates in MySQL? I am more interested
How can I make a perfect backup of mysql database using mysqldump? When I
I'm trying to use ON CASCADE DELETE in mysql db but I can't make

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.