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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:04:56+00:00 2026-05-26T04:04:56+00:00

Consider the following table structure (not designed by me, and unchangable): +—————+—————————–+—————————+ | the_id

  • 0

Consider the following table structure (not designed by me, and unchangable):

+---------------+-----------------------------+---------------------------+
|    the_id     |         field_name          |        field_value        |
+---------------+-----------------------------+---------------------------+
|      1        |           county            |       lincolnshire        |
|      1        |            type             |           hotel           |
|      2        |           county            |       lincolnshire        |
|      2        |            type             |          castle           |
+---------------+-----------------------------+---------------------------+

Basically, I want to perform a search on this data, returning the_id of anything that matches the parameters I specify. So, for example I want to search for all the_id fields which have (field_name = county AND field_value = lincolnshire) AND (field_value = type AND field_value = castle). Thus, only 1 would be returned.

Essentially, I want to know if it’s possible to perform a search on the returned results. Since the fields are completely separate entities linked by the_id, here’s what I’m thinking in pseudo-code:

  • Look up county
  • Search for the_id and type in the results
  • Return sub-set.

The problem is, I’m not 100% sure how this could be implemented in MySQL. Any feedback would certainly be gratefully received!

  • 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-26T04:04:56+00:00Added an answer on May 26, 2026 at 4:04 am

    Ah, the joys of using an SQL database as key-value stores, because it makes the DB schema so much simpler… first off, take the original designer of this system out back and beat them up with a rotten wet fish, preferably whale-sized, dropped from a great height.

    then…

    SELECT the_id, type, county
    FROM (
        SELECT type_name.the_id AS the_id, type.field_value AS type, county.field_value AS county
        FROM yourtable AS type
        LEFT JOIN yourtable AS county ON county.the_id = type.the_id AND county.field_name='county'
        WHERE type.field_type = 'type'
    ) AS child
    WHERE county='lincolnshire'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider following sample table structure: +-------------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null |
Consider the following table: mysql> select * from phone_numbers; +-------------+------+-----------+ | number | type
Consider the following structure : alt text http://aeon-dev.org/pap/pap_db.png Ignore the table user_token. Now, imagine
Consider the following table: +-------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key |
Consider the following table: CREATE TABLE `prize` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `prize_details_id`
Consider the following database schema: create table UserGroup ( id int not null auto_increment,
Consider the following table structure with data - AdjusterID | CompanyID | FirstName |
Consider the following table and its indexes: CREATE TABLE 'Interaction' ( 'oid' bigint(20) NOT
Consider the following table: CREATE TABLE Participations ( roster_id INTEGER NOT NULL, round_id INTEGER
Please consider the following table structure on Oracle: create table DOCS ( DOC_NO NUMBER

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.