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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:01:48+00:00 2026-05-27T02:01:48+00:00

I need to compare 2 tables, where one has the data and the other

  • 0

I need to compare 2 tables, where one has the data and the other one has the explanation.

So the data table looks like this:

id  | state | substate | stage | suppressed
001    wip     A1          B3        Y
003    wip     A1          B1        N
005    done    A2          B3        Y
009    wip     A1          B3        N
... and many more similar

The explanation table has to get the 4 states above (state, substate, stage, suppressed) and translates them to human readable:

state | substate | stage | suppressed | HRoutput1     | HRoutput2
wip        A1        B1        N        "it's ok"       "wait...dont do anything"
wip        A1        B3        N        "it's not ok"   "better call saul"
done       A2        B3        Y        "it's not ok"   "forget about it"
wip        A1        B1        Y        "it's ok"       "something minor needs to be done"
*          *         *         Y        "it's ok"       "it's suppressed"
done       *         *         *        "it's ok"       "it's being worked on"

Now see the above explanation table has 2 stages where i used wildcards in the table

*,*,*,Y,"it's ok","its suppressed"

This should be used when state, substate, stage and suppressed are not matched in any of the above criteria.

What I did until now is, I loaded each line on the data into an array A
then let the element array A run through the explanation table:

 "SELECT * from explanation_table where state = '" . $data['state'] ."' and '" . $data['substate'] . "' ....etc etc

Then ran the query and saved the result into an explanation array and printed the result

 $data['id'] .  $expl['HRoutput1'] .  $expl['HRoutput2']

My code worked fine except for the cases with wildcards.

  • 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-27T02:01:49+00:00Added an answer on May 27, 2026 at 2:01 am

    To resume from your query, you could do:

    "SELECT * from explanation_table where (state = '" . $data['state'] ."' OR state = '*') and (substate = '" . $data['substate'] . "' OR substate = '*') ....etc etc.... ORDER BY state != '*', substate != '*' ... LIMIT 1
    

    This way, you’ll match both wildcards and exact state/substate/… matches, valueing the real matches higher than the wildcard matches (the order by) and returning only the best matching result.

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

Sidebar

Related Questions

I need to compare two columns in a sql table. The data in one
When you need to compare two tables to see what the differences are, are
I need to compare the answer in with the aspnet_membership tables PasswordAnswer value. The
I need to compare two account number columns from two different tables to see
I have two tables: one table (okay, it's a view), vComputer, lists many computers
Parsing some data and inserting it into 3 tables from .NET. Using Table Valued
I currently have 2 tables, one is idtracker which has around 30,000 rows and
Dear Programmers, I need to compare one column value to another column in single
My dataframe(m*n) has few hundreds of columns, i need to compare each column with
I need to use PHP to copy data from one MySQL database to another.

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.