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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:51:37+00:00 2026-06-04T17:51:37+00:00

I have the following tables in my database which I cannot change or modify.

  • 0

I have the following tables in my database which I cannot change or modify. I kept the Log table simple but LogDetail is the same as in my database.

Log Table

 Id  User Department Service     Method

 21  John Sales      UserService GetUser

LogDetail Table

Id LogRef ParamName  ParamValue

30 21     FirstName  Adam
31 21     LastName   Smith     
32 21     Age        35
33 21     Gender     M

Now, I am using following query to get who searched (Adam, Smith, 35, M)

SELECT 
L.*, D1.ParamName, D2.ParamName, D3.ParamName, D4.ParamName
FROM Log as L
INNER JOIN LogDetail as D1 on L.Id = D1.LogRef
INNER JOIN LogDetail as D2 on L.Id = D2.LogRef
INNER JOIN LogDetail as D3 on L.Id = D3.LogRef
INNER JOIN LogDetail as D4 on L.Id = D4.LogRef
WHERE
D1.ParamName='FirstName' and D1.ParamValue='Adam' and
D2.ParamName='LastName' and D2.ParamValue='Smith' and
D3.ParamName='Age' and D3.ParamValue=35 and
D4.ParamName='Gender' and D4.ParamValue='M'

Is there a better way to do this?

  • 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-04T17:51:38+00:00Added an answer on June 4, 2026 at 5:51 pm

    This is what happens when you use an EAV schema (key-value pairs basically)

    There isn’t much you can except add an index on (ParamName, ParamValue) for LogDetail. This assumes the clustered index stays as LogRef

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

Sidebar

Related Questions

I have the following listbox below which binds to a database table of image
I have a database which consists of the following: ** Table 1 ** Id
I have the following tables in a database (i'll only list the important attributes):
I have the following (simplified) database tables: Products - ProductID, int, PK - Name,
I have the following tables, with these keys in my database: bookings session_id sessions
I have a database with the following tables, Member, Paper, Topic, Interest, Associated. I
I have two database tables with the following structure: actions: action_id int(11) primary key
I have a database with two tables, tblPlayers and tblMatches. tblPlayers contains the following
I have the following table in my database. Now what I want to find
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation

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.