mysql - Select within a select slow -


i use select within select check if data exists in table:

select     a.id,     a.desc,     a.serial,     a.partno,     a.maintact,     a.lcnalc,     a.datedue,     a.intrem,     a.lifetype,     (select b.id assets b         (b.maintact = a.maintact) ,         (b.aircraft_id = a.aircraft_id) ,         (b.inittype = "strt") ,         (b.initlcnalc = a.lcnalc or b.initlcnalc = "")) parent     assets aircraft_id = 6; 

what know more efficient way above query?

try using join faster:

select     a.id,     a.desc,     a.serial,     a.partno,     a.maintact,     a.lcnalc,     a.datedue,     a.intrem,     a.lifetype,     b.id assets  join assets b     on (b.maintact = a.maintact) ,     (b.aircraft_id = a.aircraft_id) ,     (b.inittype = "strt") ,     (b.initlcnalc = a.lcnalc or b.initlcnalc = "") a.aircraft_id = 6; 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -