entity-attribute-value

SQL Server, where field is int?

醉酒当歌 提交于 2019-12-01 18:04:07
how can I accomplish: select * from table where column_value is int I know I can probably inner join to the system tables and type tables but I'm wondering if there's a more elegant way. Note that column_value is a varchar that "could" have an int, but not necessarily. Maybe I can just cast it and trap the error? But again, that seems like a hack. select * from table where column_value not like '[^0-9]' If negative ints are allowed, you need something like where column_value like '[+-]%' and substring(column_value,patindex('[+-]',substring(column_value,1))+1,len(column_value)) not like '[^0-9]

SQL Server, where field is int?

老子叫甜甜 提交于 2019-12-01 17:27:20
问题 how can I accomplish: select * from table where column_value is int I know I can probably inner join to the system tables and type tables but I'm wondering if there's a more elegant way. Note that column_value is a varchar that "could" have an int, but not necessarily. Maybe I can just cast it and trap the error? But again, that seems like a hack. 回答1: select * from table where column_value not like '[^0-9]' If negative ints are allowed, you need something like where column_value like '[+-]%'

Select products by multiple attributes, using AND instead OR concatenator, Data model EAV

喜夏-厌秋 提交于 2019-12-01 08:47:24
I have an issue with a query for eCommerce website products filter. I have EAV data model like this: products [id, title....] attributes [id, name] attributes_entity [product_id, attribute_id, value_id] attributes_values [id, value] My query: SELECT products.id, products.title FROM products WHERE products.id IN ( SELECT attributes_entity.product_id FROM attributes_entity INNER JOIN attributes ON attributes_entity.attribute_id=attributes.id INNER JOIN attributes_values ON attributes_entity.value_id=attributes_values.id WHERE ( (attributes.name="Memory" AND attributes_values.value="16GB") >> AND

MySQL search products with their attributes

馋奶兔 提交于 2019-12-01 08:04:54
I have a MySQL database that contains products with their group/attributes/ i created a sample of data in http://sqlfiddle.com/#!2/7d8a04/1 create table products ( id int(10), title varchar(50) ); create table attributes ( id int(10), title varchar(50) ); create table filters ( id int(10), attribute_id int(10), title varchar(50) ); create table product_filters ( id int(10), product_id int(10), attribute_id int(10), filter_id int(10) ); #products insert into products select '1', '1stphone'; insert into products select '2', '2ndphone'; #attributes insert into attributes select '1', 'ram'; insert

MySQL: how to convert to EAV?

六眼飞鱼酱① 提交于 2019-12-01 08:03:45
Say I have the following table: TABLE: one =============================== | id | first_name | last_name | =============================== | 1 | John | Doe | | 2 | Jane | Smith | ------------------------------- I want to convert it to an EAV: TABLE: two =================================== | id | fk_id | attribute | value | =================================== | 1 | 1 | first_name | John | | 2 | 1 | last_name | Doe | | 3 | 2 | first_name | Jane | | 4 | 2 | last_name | Smith | ----------------------------------- Note: two.fk_id values came from one.id two.attribute values came from one.first_name

Select products by multiple attributes, using AND instead OR concatenator, Data model EAV

ε祈祈猫儿з 提交于 2019-12-01 06:25:51
问题 I have an issue with a query for eCommerce website products filter. I have EAV data model like this: products [id, title....] attributes [id, name] attributes_entity [product_id, attribute_id, value_id] attributes_values [id, value] My query: SELECT products.id, products.title FROM products WHERE products.id IN ( SELECT attributes_entity.product_id FROM attributes_entity INNER JOIN attributes ON attributes_entity.attribute_id=attributes.id INNER JOIN attributes_values ON attributes_entity

MySQL search products with their attributes

眉间皱痕 提交于 2019-12-01 05:46:34
问题 I have a MySQL database that contains products with their group/attributes/ i created a sample of data in http://sqlfiddle.com/#!2/7d8a04/1 create table products ( id int(10), title varchar(50) ); create table attributes ( id int(10), title varchar(50) ); create table filters ( id int(10), attribute_id int(10), title varchar(50) ); create table product_filters ( id int(10), product_id int(10), attribute_id int(10), filter_id int(10) ); #products insert into products select '1', '1stphone';

How and where to modify Magento search query?

自闭症网瘾萝莉.ら 提交于 2019-12-01 02:48:45
First of all, I found similar questions in SO but there is not any answer for them. So, the first part of the question is a little bit duplicated. I want to improve search results in Magento. Here is what I've done already: 1. Search with AND instead of OR when there are multiple words. 2. Ajax search starts searching from anywhere and not only from the beginning of the fields. 3. Trim the last s from the words to prevent empty results when searching with plurals. 4. I changed the search type from Like to Fulltext or Combine but the results were not better and even were worst, so I leave it as

How to optimize this complicated EAV MYSQL query?

感情迁移 提交于 2019-11-30 23:14:47
Is it possible to optimize this query I have written I've created a sort of dynamic virtual database to give my users the ability to add custom fields without affecting the database structure. Here is a very simplified view of the stucture so far. tables | columns db_cases | caseid db_structure | fieldname db_data | fieldname, data, caseid db_names | nameid We can create a new field by adding a row to db_structure Any data we wish to record is recorded to db_data. Names are stored in db_names and the name_id is stored in db_data I am trying to output the cases to a html table Hopefully the

How and where to modify Magento search query?

懵懂的女人 提交于 2019-11-30 22:32:24
问题 First of all, I found similar questions in SO but there is not any answer for them. So, the first part of the question is a little bit duplicated. I want to improve search results in Magento. Here is what I've done already: 1. Search with AND instead of OR when there are multiple words. 2. Ajax search starts searching from anywhere and not only from the beginning of the fields. 3. Trim the last s from the words to prevent empty results when searching with plurals. 4. I changed the search type