string - mysql left join empty varchar both side (MyISAM) -


i have join 2 table varchar columns. both of columns contain multiple empty values want ignore them. inner join query works fine :

select count(*) tbl1 t1  join tbl2 t2 on t1.col = t2.col , t1.col <> '' 

but need left join :

select count(*) tbl1 t1  left join tbl2 t2 on t1.col = t2.col , t1.col <> '' 

and 1 taking 20-30 seconde execute... think it's doing join operation before cuts empty values. can't found solution force <> '' condition first.

same request without condition take same execution time :

select count(*) tbl1 t1  left join tbl2 t2 on t1.col = t2.col 

but return 50 000 000 vs 150 000 first one.

tbl1 : 'ooooa' 'fieldtbl1' 'oooob' 'fieldtbl1' 'ooooc' 'fieldtbl1' 'ooood' 'fieldtbl1' ''      'fieldtbl1'  tbl2 : 'ooooa' 'fieldtbl2' 'oooob' 'fieldtbl2' 'ooooc' 'fieldtbl2' ''      'fieldtbl2'  expected result : 'ooooa' 'fieldtbl1'   'fieldtbl2' 'oooob' 'fieldtbl1'   'fieldtbl2' 'ooooc' 'fieldtbl1'   'fieldtbl2' 'ooood' 'fieldtbl1'   null ''      'fieldtbl1'   null 

is there way ?

as @matteo tassinari said, condition failure of together. why takes long time process, need delete 1 of them:

 t2.col <> '' 

or

t1.col <> '' 

because used t1.col = t2.col in where clause (on).

in fact full code should thing this:

select * tbl1 t1  left join tbl2 t2 on t1.col = t2.col , t2.col <> '', 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -