MySQL match against with 2 fields -
i have problem match() against() in mysql. cant match 2 columfields against each other, if use procedure, thats clear.
now problem: have query search double entries (only technnical data):
select t1.acid,t2.acid, t1.brand, t2.modelnamerough,t1.modelnamedetail, t2.modelnamedetail,......... ref_web_tb t1 join ref_web_tb t2 on t1.brand = t2.brand , t1.modelnamerough = t2.modelnamerough , t1.bodytype ....(alot of other things compare) , (t1.acid < t2.acid)
but thats not enough. there field called "modelnamedetail" locks like: "1.9 tdi comfort variant dpf" or "1.9 tdi comfortline variant dpf"
(only line in comfort different, both of cars have different prices , on, same technical data)
so have match t1.modelname against t2.modelname , use score check if name same. (otherwhise loooooot of data check if there double entry, because there alot of cars same technical data in same roughmodel)
the procedure match() against() no problem, this: (just test)
delimiter $$ drop procedure if exists `offensichtlich_doppelte` $$ create procedure `offensichtlich_doppelte` (search_string text) deterministic reads sql data begin select t1.acid, t1.brand,t1.modelnamerough,t1.modelnamedetail, match (t1.modelnamedetail) against (search_string) score ref_web_tb t1 limit 50; end $$ delimiter ;
but have no idea how use query results procedure?! im totaly confused ;( can give me hint how can solve problem?
and short question: stuff "gearboxtype" null. if 1 of technical fields null, wontget listed. can like:
select * ref_web_tb t1 join ref_web_tb t2 on .... , if gearboxtype null ignore gearboxtype ....
?
i thought like:
select * ref_web_tb t1 join ref_web_tb t2 on .... , if(t1.gearboxtype null, ignore, t1.gearboxtype = t2.gearboxtype) ....
would work, seems not, because dont know how ignore case ;( (wait .. case maybe answer? )
thanks reading ;)
as first question, think cursors looking for.
first, need declare variables in procedure, store data get.
declare char(10); declare b int;
since cursor can traversed 1 time, have handle not found
exception @ end of it.
declare done int default false; declare continue handler not found set done = true;
then declare cursor
fetch data.
declare results cursor select stuff, otherstuff sometable;
this creates cursor. have open it, in order execute query:
open results;
to results of query, then, iterate on cursor:
read_loop: loop fetch results a, b; if done leave read_loop; end if; --do business here , b end loop;
and, finally, close cursor:
close results;
hope helps.
Comments
Post a Comment