-4
什麼是簡化查詢的最佳方式?如何簡化MySQL PHP查詢
$sql = "SELECT "
."b.barber_id, b.likes, b.shop_id, "
."s.shop_name, s.shop_address, s.shop_city, s.shop_state, s.shop_zip, s.shop_phone, s.shop_website, "
."bl.leave_time, bl.return_time, "
."bw.work_day_start, bw.work_day_end, "
."bd.days "
."FROM "
."barbers b, shops s, barber_lunch_break bl, barber_work_hours bw, barber_days_off bd "
."WHERE "
."b.user_id = ? "
."AND s.shop_id = b.shop_id "
."AND bl.barber_id = b.barber_id "
."AND bw.barber_id = b.barber_id "
."AND bd.barber_id = b.barber_id";
如果您要從多個表中選擇數據,請使用連接。 –
具有適當的索引 –