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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:53:31+00:00 2026-05-27T03:53:31+00:00

I am using postgresql. I have a table called custom_field_answers. The data looks like

  • 0

I am using postgresql.

I have a table called custom_field_answers. The data looks like this

Id | product_id | value      | number_value | 
4  | 2          |            | 117          |
3  | 1          |            | 107          |
2  | 1          | bangle     |              |
1  | 2          | necklace   |              |

I want to find all the products which has text_value as ‘bangle’ and number_value less than 50.

Here was my first attempt.

SELECT "products".* FROM "products" INNER JOIN "custom_field_answers" 
ON "custom_field_answers"."product_id" = "products"."id" 
WHERE ("custom_field_answers"."value" ILIKE 'bangle')

Here is my second attempt.

 SELECT "products".* FROM "products" INNER JOIN "custom_field_answers" 
ON "custom_field_answers"."product_id" = "products"."id" 
where ("custom_field_answers"."number_value" < 50)

Here is my final attempt.

SELECT "products".* FROM "products" INNER JOIN "custom_field_answers" 
ON "custom_field_answers"."product_id" = "products"."id" 
WHERE ("custom_field_answers"."value" ILIKE 'bangle') 
AND ("custom_field_answers"."number_value" < 50)

but this does not select any product record.

  • 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-27T03:53:32+00:00Added an answer on May 27, 2026 at 3:53 am

    A WHERE clause can only look at columns from one row at a time.

    So if you need a condition that applies to two different rows from a table, you need to join to that table twice, so you can get columns from both rows.

    SELECT p.*
    FROM "products" AS p
    INNER JOIN "custom_field_answers" AS a1 ON p."id" = a1."product_id"
    INNER JOIN "custom_field_answers" AS a2 ON p."id" = a1."product_id" 
    WHERE a1."value" = 'bangle' AND a2."number_value" < 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that looks basically like this: id | redirectid | data
I am using PostgreSQL. I have the data in table like: Parent_id Count Read
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
I'm using PostgreSQL 9.0 and I have a table with just an artificial key
I'm using PostgreSQL 8.4.6 with CentOS 5.5 and have a table of users: #
I am using python and postgresql. I have a table with 6 column. One
Say I have a table like this: x1 | y1 | x2 | y2
I have the following data in my Street_Address_1 column: 123 Main Street Using Postgresql,
I have loaded a huge CSV dataset -- Eclipse's Filtered Usage Data using PostgreSQL's
Using PostgreSQL triggers, is it possible to record the changes that have happened to

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.