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

The Archive Base Latest Questions

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

Thank you for all the help I have received here and yet, here I’m

  • 0

Thank you for all the help I have received here and yet, here I’m with a complementary question.

Setup

I have 3 relevant tabels in MySQL:

STRINGVALUES
ID   ItemID   Key    Value
1    1        Note   My note book is electronica

INTEGERVALUES
ID   ItemID Key    Value
1    1      Color  2
2    1      Type   4

STRINGS
ID   Value
1    Stone
2    Red
3    Blue
4    Phone

Other fields has been removed to only show what is relevant.
ItemID is the identifier for an Article. In this case I have only entered information for Article 1 (ItemID=1)

The INTEGERVALUES table uses the Value as an ID to lookup a value in the STRINGS table (hence a separate table with only integers). The strings table also have support for multiple languages while StringValues are data entered by users.

Desired result

The SQL query I have now looks like this:

SELECT i.*, ai.Key, ai.Value,
(SELECT s.Value FROM Strings s WHERE ai.Value=s.StringID) sValue,
(SELECT ats.Value FROM attributestrings ats WHERE ats.ItemID=i.ItemID) sValue
FROM items i
INNER JOIN AttributeIntegers ai ON i.ItemID=ai.ItemID
WHERE i.ID = 1

This gives me the relevant result

ItemID Key    Value  sValue  sValue
1      Color  2      Red     My note book is electronica
1      Type   4      Phone   My note book is electronica

What I want is this result:

ItemID Key    Value  sValue
1      Color  2      Red
1      Type   4      Phone
1      Note   Null   My note book is electronica

I’m trying to read up on UNION but I don’t know if it is the right answer…

Thanks.

  • 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-19T02:44:27+00:00Added an answer on May 19, 2026 at 2:44 am
    SELECT  *
    FROM    (
            SELECT  itemid, key, iv.value, s.value AS svalue
            FROM    integervalues iv
            JOIN    strings s
            ON      s.id = iv.value
            WHERE   iv.itemid = 1
            UNION ALL
            SELECT  itemid, key, NULL, value
            FROM    stringvalues sv
            WHERE   sv.itemid = 1
            ) vals
    JOIN    items i
    ON      i.id = vals.itemid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for your help! I'd like to output all companyName entries that have uploads
First, I would to thank everyone for all the help they provide via this
First, thanks for all the help I've received so far from StackOverflow. I've learned
EDIT: I have fixed all but two warnings now, so thank you all for
Here is my code: (Thank you MurifoX) <% random_bullets = Bullet.all %> <ul> <%
I have a simple script written to process received email. Here are the tested
I have a problem with a MySql server causing it to freeze all the
I have written an HTTP proxy that does some stuff that's not relevant here,
Thank you all for helping. Below this post I put the corrected version's of
First of all thank you for your time and sorry if some issues are

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.