Home > Back-end >  I don't know how to create sql query api php?
I don't know how to create sql query api php?

Time:08-24

I don't know how to create android api php.If you know please let me know.Menu table this is Subcategory this is tbl_recipes this is detail page this is how to prepare api with this.how to use left joining with this.Menu,Subcategory ,tbl_recipes How to bring joining with these 3 tables i am new devloper

Menu table this

INSERT INTO `menu` (`mid`, `menu_Name`, `menu_icon`) VALUES
(1, 'dfhg', '4198-2022-08-18.png'),
(2, 'husfushdf', '9619-2022-08-18.jpeg'),
(3, 'asf', '0356-2022-08-17.png'),

Subcategory this

 INSERT INTO `tbl_category` (`cid`, `category_name`, `category_image`, `menu_id`) VALUES
(25, 'dfg', '3523-2022-08-23.png', 12),
(26, 'tytry', '6412-2022-08-23.png', 13);

this details page

 INSERT INTO `tbl_recipes` (`recipe_id`, `cat_id`, `recipe_title`, `menu_id`, `recipe_description`, `recipe_image`, `video_url`, `video_id`, `content_type`, `size`, `featured`, `tags`, `total_views`, `last_update`) VALUES
(47, 0, 'dsg', 0, '<p>sg</p>\r\n', '1661254132_Screenshot (6).png', '', 'cda11up', 'Post', '', 0, '0', 0, '2022-08-23 11:28:52'),
(48, 14, 'sad', 0, '<p>asdasd</p>\r\n', '1661254498_Ent-card-1.jpg', '', 'cda11up', 'Post', '', 0, '0', 0, '2022-08-23 18:57:49'),
(49, 25, 'fgh', 13, '<p>fghfgh</p>\r\n', '1661280418_Screenshot (5).png', '', 'cda11up', 'Post', '', 0, '0', 0, '2022-08-23 18:57:44'),
(50, 25, 'try', 13, '<p>tyt</p>\r\n', '1661281058_Screenshot (5).png', '', 'cda11up', 'Post', '', 1, '0', 0, '2022-08-23 18:57:54');

CodePudding user response:

Try below SQL query

select tbl_recipes.*, tbl_category.category_name, tbl_category.category_image, menu.menu_name, menu.menu_icon from tbl_recipes
left join tbl_category on tbl_recipes.cat_id=tbl_category.cid
left join menu on tbl_recipes.menu_id=menu.mid
  • Related