localkaste Posted July 4, 2010 Report Posted July 4, 2010 sveiki. netieku galā ar vienu meklēšanas query :( ceru uz palīdzību šajā forumā! tātad pati problēma! sql tabulu struktūra: create table if not exists products ( id mediumint(8) unsigned auto_increment primary key, name varchar(300), price double ) engine=innodb; create table if not exists attributes ( id mediumint(8) unsigned auto_increment primary key, name varchar(300) ) engine=innodb; create table if not exists attribute_values ( id mediumint(8) unsigned auto_increment primary key, attribute_id mediumint(8) unsigned, name varchar(300) foreign key (attribute_id) references attributes(id) on delete cascade ) engine=innodb; create table if not exists checked_attributes ( product_id mediumint(8) unsigned, attribute_value_id mediumint(8) unsigned, foreign key (product_id) references products(id) on delete cascade, foreign key (attribute_value_id) references attribute_values(id) on delete cascade ) engine=innodb; products: produktu dati attributes: produkta atribūti attribute_values: produkta atribūta vērtības checked_attributes: šeit glabājas id ar atķeksētajiem produkta atribūtiem un meklēt vajadzētu gan gan produktu nosaukumos: products->name, gan atribūtos attributes->name, bet tikai tādos kuri ir atķeksēti: checked_attributes tabulā. paldies jau iepriekš ;) Quote
werd Posted July 4, 2010 Report Posted July 4, 2010 (edited) SELECT products.name,attributs.name FROM products,attributs,checked_attributs WHERE attributes.id = checked_attributes.attribute_value_id... Edited July 4, 2010 by werd Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.