How do I change this large query in a stored process and what else? What will be the benefit?
select from user_items items on the left JOIN (items.item_id = user_items.item_id) on the inside item_categories JOIN (item_categories.item_id = items.item_id) on the inside (item_subcategories. Item_id = items.item_id) Join inbound brands (brands.brand_id = items.item_brand) at item_photos Join item (item_photos.item_id = items.item_id) on interiors (place_items.item_id = item place_items include item_subcategories included. ITEM_ID) places on the inside JOIN (places.place_id = place_items.place_id) where user_items.user_id =: user_id
- < Code> place_name
brands
table I only need Location
brand_name
brand
and locations
, so a friend of mine told me that I should probably consider using stored procedures
If you want a column from the Brands and Items table, you can do the following:
Pre> "SELECT brand.brand_name, places.place_name, user_items. *, item . *, Item_categories. *, Item_subcategories. *, Item_photos *, Place_items * Items from the user_items on the left are JOIN (items.item_id = user_items.item_id) on the inside item_categories JOIN (item_categories.item_id = items.item_id) Insert item_subcategories (item_subcategories.item_id = items.item_id) on the inside (brands.brand_id = Items.item_brand) Join inner brands at item_photos JOIN (item_photos.item_id = items.item_id) on interiors (place_items.item_id = items.item_id) Insert include place_items but places (places.place_id = place_items.place_id) Where user_items.user_id =: user_id "
Uses of a stored procedure can be used to reuse a set of SQL statements. The performance of the collected procedure will be good as that SQL statement.
The better way to improve your code's better readability is to use ALIASES for table names.
Comments
Post a Comment