c# - SQL SELECT depending on multiple variables and tables -
i'm trying create select
query, problem here multiple variables suitable different table.
to make clear i'll present database tables :
category
catid catname
subcategory
catid subcatid subcatname
company
companyid compname subcat
model
compid modelid modelname
posts
postid modelid
now, parameters : cat, subcat, category, modelid , name, , need select matching results of postid suits parameters.
e.g, if following parameters :
cat = "electronics" subcat="computers" company="apple" modelname="macbook air" keyword="new"
i need following results of posts category equals cat variables, , subcategory matches subcat variable , on.. , in addition filter result using %like%
keyword variable got.
unfortunately failed after lot of tries trying solve it. tried using inner join in different ways, didn't work.
i appreciate if can me this, because got not idea how continue form point, , don't have lot of time till need finish project.
thanks in advance
select posts.* posts inner join model on posts.modelid = model.modelid , model.modelname = 'macbook air' inner join company on model.compid = company.companyid , company.compname = 'apple' inner join subcategory on company.subcat = subcategory.subcatid , subcategory.subcatname ='computers' inner join category on subcategory.catid = category.catid , category.catname = 'electronics' posts.keywordfield '%new%'
i had make assumptions there, field trying search keyword in. general idea: @ each inner join can specify additional condition limit results, , in manner apply parameters query.
Comments
Post a Comment