Saturday 15 January 2011

mysql - JOIN ON Coalesce(Formula1,Formula2,Formula3) -


Using MySQL, I am trying to do a JOIN as you OR statements with the join such as:

  join biogeuse on (biogyguide.info = house distinction) or (left (biogeoid.firstnames, 3 ) = Left (house.first, 3) and bioguide.lastname = house.last) or (bioguide.fulldistrict = house.districtname and bioguide.lastname = house.last)   

Probably in the form, it is the problem of doing this in such a way that if different A bunch of issues you've got some results in each row work.

I hope that JOIN and the way it uses the COALESCE function, essentially stating (though it does not work): Bio Biogeide (biogeoid.name = House.first and bioguide.lastname = house.last) at COINESCE, (left (biogeoid.name, 3) = left (home, first, 3 ) And biogeoid. Unknown name = house.last), (biogas.final district = house.districtname and bioguide.l astname = house.last))

If it works, then This will call SQL first JOIN on (Bioguide.firstname = house.first and bioguide.lastname = house.last) then at (left) (first name, biotic. 3) = left (house.first, 3) and bioguide.lastname = House.last), etc.

Is such a thing possible? Please tell me if other information will be useful.

Thanks everyone!

You can create queries in separate tables in separate matches, and then you You can use coalesce () in the selection to get:

  Select from collage (BG1 Col1, bg2.col2, bg3.col3). . On the left outer join biogaside BG1 BG1 Bulldlistride = House DstxtName Left Exterior Biogas BG 2 Left (BG 2. FirstName, 3) = Left (house.first, 3) and BG2. Anonymous = Home Leave on the left outer biogas BG3 Bg3.fulldistrict = house.districtname and bg3.lastname = house.last   

This can still be the result in many rows, if one of the comparisons There are several matches for (If there is a match between biogas three in the same row, you have no problems in the duplicated rows.)

If this is so, then prudently Use group : by group & lt; ID column that sets each row in the result set & gt;

No comments:

Post a Comment