feri_soft Posted April 24, 2006 Share Posted April 24, 2006 So how to put many parameters into the where clause.For example i have 5 cat ids and i want to select alldata that matches one of the 5 categories.CAn you give me the sql code please ;) Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/ Share on other sites More sharing options...
Barand Posted April 24, 2006 Share Posted April 24, 2006 Something like[code]SELECT ... whatever... FROM tablename WHERE catID IN (1,2,3,4,5)[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30231 Share on other sites More sharing options...
feri_soft Posted April 25, 2006 Author Share Posted April 25, 2006 And one more question.I have the cat ids in the articles table,but the categories names are in other table,so how when i am listing the articles instead of the catid to list the catego ry name.How to joint the tables or...i dont know. Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30416 Share on other sites More sharing options...
Barand Posted April 25, 2006 Share Posted April 25, 2006 [code]SELECT a.name, a.author, c.cat_nameFROM article a INNER JOIN categories c ON a.cat_id = c.cat_id[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30464 Share on other sites More sharing options...
feri_soft Posted April 25, 2006 Author Share Posted April 25, 2006 I understood that category and article are my tables but what are all those a and c.If i put the code exactly as is would it work or the a and c must be changed? Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30511 Share on other sites More sharing options...
feri_soft Posted April 25, 2006 Author Share Posted April 25, 2006 bump Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30604 Share on other sites More sharing options...
Barand Posted April 25, 2006 Share Posted April 25, 2006 They are table aliases, defined in the queryFROM article [b]a[/b]INNER JOIN categories [b]c[/b]It makes the query easier to read than[code]SELECT article.name, article.author, categories.cat_nameFROM articleINNER JOIN categories ON article.cat_id = categories.cat_id[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30647 Share on other sites More sharing options...
feri_soft Posted April 26, 2006 Author Share Posted April 26, 2006 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-30904 Share on other sites More sharing options...
feri_soft Posted April 29, 2006 Author Share Posted April 29, 2006 hmmm,how to select c.cat_name from articles as it is not in the articles table but the categories !? Quote Link to comment https://forums.phpfreaks.com/topic/8282-help-with-mysql-where/#findComment-31963 Share on other sites More sharing options...
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.