Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. SELECT SQL_CALC_FOUND_ROWS SQL_NO_CACHE I.*, S.Description AS StatusDescription, J.IdOwner
  2. FROM users
  3. STRAIGHT_JOIN rights R USE INDEX (IdUsers) ON R.IdUsers = U.id
  4. STRAIGHT_JOIN owners O ON R.IdOwners = O.Id AND U.ClientId = O.IdClients
  5. STRAIGHT_JOIN jobs J USE INDEX (IdOwner) ON O.Id = J.IdOwner
  6. STRAIGHT_JOIN items I USE INDEX (IdJobs) ON J.Id = I.IdJobs
  7. INNER JOIN sendingtypes St ON St.Id = I.IdSendingTypes
  8. INNER JOIN status S ON S.Id = I.IdStatus
  9. WHERE U.id = 1
  10. AND I.FirstEndUserViewTime IS NULL OR I.FirstEndUserViewTime = O
  11. AND I.CreationDate >= 2018-2-19
  12. ORDER BY I.Date DESC, I.CreationDate DESC, I.Id DESC
  13. LIMIT 10 OFFSET 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement