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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:04:12+00:00 2026-06-05T20:04:12+00:00

I have a following table named [clients] with columns and values as follows: +——–+———–+————–+—————-+

  • 0

I have a following table named [clients] with columns and values as follows:

+--------+-----------+--------------+----------------+
| uid    | client_id | client_input |  input_value   |
+--------+-----------+--------------+----------------+
| 1      |   22      |  City        |  Seattle       |
+--------+-----------+--------------+----------------+
| 2      |   45      |  City        |  Ojai          |
+--------+-----------+--------------+----------------+
| 3      |   22      |  State       |  OR            |
+--------+-----------+--------------+----------------+
| 4      |   45      |  State       |  CA            |
+--------+-----------+--------------+----------------+
| 5      |   65      |  City        |  Orlando       |
+--------+-----------+--------------+----------------+
| 6      |   74      |  State       |  AB            |
+--------+-----------+--------------+----------------+
| 7      |   65      |  State       |  FL            |
+--------+-----------+--------------+----------------+
| 8      |   12      |  City        |  Los Angeles   |
+--------+-----------+--------------+----------------+
| 9      |   12      |  State       |  CA            |

I need PHP/MySql query which would list all the cities present in the input_value column which are located in the state of ‘CA’. Obviously the common identifier is the client_id which is always a match because if client is in ‘Los Angeles’ the same client_id is also in the row which contains the value of ‘CA’ in the input_value column. This table has over 8 million rows and any fast performing equerry is highly appreciated.

My brain fried, deadline approaching, can’t change the table design, need help, please!

  • 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-05T20:04:13+00:00Added an answer on June 5, 2026 at 8:04 pm
    SELECT *
    FROM table AS t1 INNER JOIN table AS t2 ON t1.client_id = t2.client_id
    WHERE t1.client_input = 'City' AND t2.client_input = 'State' AND t2.input_value = 'CA'
    

    Note: This may need some adjustments and could likely be optimized. But it should get you started and cool your brain.

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

Sidebar

Related Questions

I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I have a table named friends with following structure: id, from_id, to_id, confirmed, ....
So I have two tables. Table 1 is named 'appointment' with the following fields:
I have the following schema for the generation of a table/model class named Account
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
I have the following table drop table names; create table names( name varchar(200), surname
I have the following table in SQL Server 2000: TABLE_NAME | COLUMN_NAME | TYPE_NAME
I have a following table ------------ id name ------------ 1 master 2 datagrid 3
I have the following mapping: @Entity @Table(name = Prequalifications) public class Prequalification implements Serializable
I have the following entity with the following relation: @Entity @Table(name = bpr_user) public

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.