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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:58:19+00:00 2026-06-14T05:58:19+00:00

All I’m trying to do is a query for my table that contains 6

  • 0

All I’m trying to do is a query for my table that contains 6 columns with a condition that has to be met by 3 of those columns

my table’s information
table name My_table columns a1, a2, a3, a4, a5, a6

the code I have tried is below, doesn’t work of course

$myquery = "SELECT * FROM My_table WHERE a2='$variable1' AND a3='$variable2' AND a6='$variable3' ORDER BY a2 ASC";
$myresult = mysql_query($myquery);

my result has to contain the rows that met the conditions above.

What is the right way to do this?
Thanks in advance.

  • 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-14T05:58:20+00:00Added an answer on June 14, 2026 at 5:58 am

    Ok this is how I made it work, it works great for me so it could help you too.

    Since I’m comparing 3 columns of my table with 3 variables and I know that they are fix and has to meet those conditions exactly and in that order, I made a string of the 3 columns I’m searching in UPPER case then did the same with my variables then compare the against each other, that gave me the result I was looking for.

    here is the solution code to my problem:

    $myquery = "SELECT a2 a3 a6 FROM My_table WHERE concat(UPPER(a2), UPPER(a3), UPPER(a6)) LIKE concat(UPPER('$variable1'), UPPER('$variable2'), UPPER('$variable3')) ORDER BY a2 ASC";
    

    $myresult = mysql_query($myquery);

    Hopes it helps someone else too.

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

Sidebar

Related Questions

All, I am trying to create a table to receive user inputs (UGC). This
All I need is to create a file that contains a file names' list
All- I am trying to get the user's current location than display that on
All, Trying to determine how to show the name of locations of user searches
All, If I run a query like the following: $qry = Select wrong_column from
All I want to do is return the index of the i that is
all. We're trying to get some intersect collisions working, but the problem experience is
All of a sudden, Facebook sharing has stopped working on my site. It's been
All, There is a website that doesn't seem legitimate that and keeps showing all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.