score:1
Accepted answer
Hmmm . . . does this work?
select pa.product_id
from product_attribute pa left join
search_filter f
on pa.attr_name = f.name
group by pa.product_id
having sum(case when pa.value = f.value then 1 else 0 end) = count(distinct f.name);
More questions
- MS SQL - static sql query with dynamic filters
- Execute Dynamic Query with go in sql
- Working with datetime with dynamic query in SQL Server
- Crosstab Query with Dynamic Columns in SQL Server 2005 up
- Build SQL query with dynamic columns
- How to create temp table with dynamic SQL query result
- insert into select from sql query with both query and static values
- Same SQL query when run with sp_executesql is fast, very slow if executed as dynamic query in query analyser, why?
- SQL Server 2008 R2: Dynamic query for pivot table with where and having clause
- Combine Static Columns with Dynamic Columns in SQL SERVER 2008
- Dynamic SQL query with repeating elements
- How to EXECUTE dynamic query in WITH clause in SQL Server
- SQL - Dynamic SQL query to convert single column string delimited with semicolon (;) to multiple columns
- How to pivot a normal sql query with dynamic columns
- How do I combine two columns into single column in static / dynamic pivot query using SQL Server
- row_number and count very slow in query with dynamic sql and CTE, how to implement skip and take
- A dynamic column name with value in sql query
- If table exists with dynamic query in SQL Server
- SQL Search Query with Dynamic search condition
- SQL Query with Dynamic Columns Using Pivot
- Dynamic SQL query with INNER JOIN ON LIKE keyword
- Dynamic SQL Query With Dates
- Crosstab Query with Dynamic Columns in SQL Server 2008
- SQL dynamic query with synonym
- MS SQL - Parameterized Query with Dynamic Number of Parameters
- Conversion failed error with dynamic SQL query
- How can I make a dynamic SQL Server query with sliding dates but specific times?
- SQL Server query with multiple filters
- How can I execute sql in SQL Server with dynamic query
- Fatal Error due to PDO Exception because of a SQL query with dynamic PHP input
More questions with similar tag
- Django model based on an SQL table-valued function using MyModel.objects.raw()
- select case with "over partition by"
- Is there a 'START AT' equivalent in MS-SQL?
- Cannot format input parameters correctly for SQL stored procedure
- How to group count values into ranges like exactly one, 2 to 5, more than 5
- tsql while loop and time issue
- What is the best solution to design sql table relationship for a table that will be used by other tables
- Export Images stored in DB as hex files in folder
- Any National ID has an embedded space or any non-number, non-alphabet character in SQL
- How to use group by with union in T-SQL
- How to check if user has create database access in SQL Azure?
- Insert values into a table from XML (SQL Server)
- how can i display the records from the SQl server database in an array using PHP
- Table name format changed for Oracle Destination moving from SSIS 2014 to 2019
- Set Sequential Non-Identity Numbers in SQL
- TSQL complex string manipulation
- SQL query with string prefixes
- Float in Database to ? in .NET
- dax for events in progress at end of period using date table
- FIFO on inventory stocks
- Store Password for Third party login
- Splitting Date into 2 Columns (Date + Time) in SQL
- Sql Result two columns
- SQL - Calculate Customer's Percentage of Total Orders by Month
- Limit NLog Database Target Size
- Find Next Number in SQL Column
- SQL Server : JSON formatting grouping possible?
- Create a One-to-Optional-One constraint in SQL Server
- Multiple instances of SQL Server for connection vs connectionless?
- T-SQL Error Message 207 When passing values Dynamically
Source:
stackoverflow.com