1
Having the following tables in the category and subcategory bank:
CREATE TABLE categories (
  id INT AUTO_INCREMENT PRIMARY KEY,
  category_name VARCHAR(255) NOT NULL,
  created DATETIME,
  modified DATETIME
);
CREATE TABLE sub_categories (
  id INT AUTO_INCREMENT PRIMARY KEY,
  sub_category_name VARCHAR(255) NOT NULL,
  category_id INT NOT NULL,
  created DATETIME,
  modified DATETIME,
  FOREIGN KEY category_key (category_id) REFERENCES categories(id)
);
How would SQL find the subcategories given the name of a category? Ex: Select all subcategories of the Food category by passing the category name.
but I wish to select all subcategories of the Food category. (passing the category name) I edited my question to make it clearer.
– Ricardo
Hmmmm and the category name comes from where?
– Sr. André Baill
the user can type or I may automatically want to list by systematically separating by category name, but always passing the category name.
– Ricardo
I changed my answer.
– Sr. André Baill