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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:09:49+00:00 2026-06-10T19:09:49+00:00

My Mysql database has objects which are defined by an object type which is

  • 0

My Mysql database has objects which are defined by an object type which is then joined to set it’s properties. And it is based on the Entity Attribute Value model as pointed out by Spencer.

The database is a little more complicated then below but this should make my question a little more clear.

I have a mysql table objects which contains some basic information about an object say create_date, title,author and of course an id.

I also have a table object_properties which contains some more data about objects.

I have some trouble searching through them.
For example, an object might has both an end_date and start_date as a seperate property. These would each have their own row in object_properties.

How would one match the end and start date as they each have their own row?

Normally I would query it like this; select * from table where start_date > value AND end_date < value But I can’t do this because each property is a separate row.

I tried the following query; `

 select * 
  from object_properties 
 where object_id = 1 
   and (     (object_properties.type_id = 1)
         and (object_properties.value = 2) 
         and (     (object_properties.type_id = 2) 
               and (object_properties.value = 2)
             )
       )

In the example above the type_id = 1 would be the start date and type_id =2 would be the end date but this did not seem to work.
I was thinking I am looking at it the wrong way.

I realize the title of my question might be wrong, I don’t really know how storing data this way is called.

Here is the solution I used based on Matthews answer:

Here is what I ended up with: `

 SELECT   
      o.title,  
      o.id,  
      op1.value AS start_date,  
      op2.value AS end_date  
 FROM object o  
 JOIN object_meta_values op1 ON op1.object_id=o.id AND op1.object_type_meta_id=28  
 JOIN object_meta_values op2 ON op2.object_id=o.id AND op2.object_type_meta_id=29  
 WHERE object_type_id = 11  
 AND (12      <= op1.value AND op1.value <  16     )   
 OR (12       <  op2.value   AND op2.value   <= 16     )   
 OR (op1.value <= 12        AND 16        <= op2.value)  

`. Thanks alot!

  • 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-10T19:09:50+00:00Added an answer on June 10, 2026 at 7:09 pm

    You can use multiple left joins to do this.

    SELECT 
        o.create_date,
        o.title,
        o.author,
        op1.value AS start_date,
        op2.value AS end_date,
        ...
    FROM object o
    LEFT JOIN object_properties op1 ON op1.object_id=o.object_id AND op1.type_id=1
    LEFT JOIN object_properties op2 ON op2.object_id=o.object_id AND op2.type_id=2
    

    Values that do not have properties will end up being null.

    This method you don’t have to have a second query to get the properties either.

    EDIT
    If you do not want to retrieve null values, then omit the left part of the left join.

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

Sidebar

Related Questions

i have come across a mysql database which has dates entered in a varchar
I have MySQL database, where I store the following BLOB (which contains JSON object)
I have a PHP web application which uses a MySQL database for object tagging,
My MySQL database has date of birth stored in the format yyyy-mm-dd, how do
I have a mysql database that has text stored in it with non encoded
I read data from a mysql database that has is filled by php scripts.
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I've got a MySQL database that stores image information. Right now it only has
Data that is stored in my mysql database, has the breaks of text input
I have rows in a MySQL database, and each has a timestamp value. (ie

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.