How to get data table part of the query?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
There is a table with the recipe in this table refers to table ingredients. How to get php array counter containing an array of ingredients? In each iteration of the foreach to query for the ID of the recipe?
by | 8 views

2 Answers

0 like 0 dislike
Can use a SQL where in to obtain the ingredients for recipes id.

PS
You have 1 ingredient is with only one recipe? It is better to use a single table ingredients and binders table recipes <-> ingredients
by
0 like 0 dislike
Use JOIN. Like this.

SELECT * FROM recipes INNER JOIN ingredients ON recipes.id = ingredients.recipe_id


Read more about JOIN:
* https://anton-pribora.ru/articles/mysql/mysql-join/
* https://habr.com/post/44807/
* https://dev.mysql.com/doc/refman/8.0/en/join.html
by
110,608 questions
257,186 answers
0 comments
36,488 users