mysql - How does a DBMS solve the following query? -


suppose have table table1 attributes id, name, address, salary. now, write following query:

select * table1 2*salary > (select max(salary) table1) 

it obvious query

select max(salary) table1 

will produce same result each , every row in table1. dbms execute aggregation query once each row or executes once , stores value compared each row? if so, how dbms decide result of query independent of rows in table1?

because, wondering executing once each row highly inefficient.

try first store max value in variable , use variable

declare @salary money     select @salary=max(salary) #yourtable     select * #yourtable 2*salary > @salary 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -