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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:48:33+00:00 2026-06-12T11:48:33+00:00

Okay i have mysql query, and i’d like to search both parameters in table_1

  • 0

Okay i have mysql query, and i’d like to search both parameters in table_1
i’ll try showing the idea with “php”

if(table_2_params.params_id == 124){
   //select LIKE  "%EXTEC (Sandvik)%" from  table_2_params.nosaukums
}
elseif(table_2_params.params_id == 126){
  //SELECT  FROM table_2_params WHERE nosaukums is BETWEEN  "2010" AND  "2012"
}

I want to query display first AND second parameter…(both of them to match)
daymn i hope you will understand what i want to say…

Okay here’s the
mysql query:

 SELECT table_1 . * , table_2_params . * 
    FROM table_1, table_2_params
    WHERE table_1.pamat_kat_sad =  '756'
    AND table_1.preces_id = table_2_params.preces_id
    AND (
        (
        table_2_params.params_id =124
        AND table_2_params.nosaukums LIKE  "%EXTEC (Sandvik)%"
        )
        AND (
        table_2_params.params_id =126
        AND table_2_params.nosaukums
        BETWEEN  "2010"
        AND  "2012"
        )
    )
    ORDER BY table_1.preces_id DESC

Problem might be that the table_2_params.nosaukums type is longtext …

If i select only with

    AND (
    table_2_params.params_id =126
    AND table_2_params.nosaukums
    BETWEEN  "2010"
    AND  "2012"
    )

it displays correct year…
AND if i select only with

(
    table_2_params.params_id =124
    AND table_2_params.nosaukums LIKE  "%EXTEC (Sandvik)%"
    )

it also displays correct values…

But i cant make them both work together..

Please help me!

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-12T11:48:34+00:00Added an answer on June 12, 2026 at 11:48 am

    If you want two sets of conditions just use OR. You should also note that joins between tables should be performed using (INNER|LEFT) JOIN :

    SELECT
        table_1.*
        , table_2_params.* 
    FROM
        table_1
        INNER JOIN table_2_params
            ON table_1.preces_id = table_2_params.preces_id
    WHERE
        table_1.pamat_kat_sad =  '756'
        AND
        (
            (
                table_2_params.params_id =124
                AND table_2_params.nosaukums LIKE '%EXTEC (Sandvik)%'
            )
            OR
            (
                table_2_params.params_id =126
                AND table_2_params.nosaukums BETWEEN '2010' AND '2012'
            )
        )
    ORDER BY
        table_1.preces_id DESC
    

    And finally your query may perform poorly, since mysql won’t be able to use any index with AND table_2_params.nosaukums LIKE '%EXTEC (Sandvik)%'

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

Sidebar

Related Questions

I have a problem with (for me to complicated) MySql query. Okay, here is
Okay, basically, I have formed a mySQL query which returns a data set all
Okay, here's what I'm trying to do. I am running a MySQL query for
Okay so I have this web site search script and I'm trying to count
Okay, so I have a MySQL database set up. Most of the tables are
OKay, I will try to make this make sense lol. Basically I have 4
I have a table with zipcode(int) and Location(point). I'm looking for a MySql query
I have a web application written in PHP. It uses MySQL for data storage.
Okay, so I have these two tables in MySQL. One is called 'History' and
hello i have some problems with my php ajax script i'm using PHP/mysql i

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.