PDA

View Full Version : field concatenation?


djdante97
04-15-2003, 01:44 AM
Hi there,
I'm wondering if there's a way to concatenate attributes and compare them with another attribute in the same table?

Basically, i have a table with a house number, street number, city, etc. , and also a field 'registrantAddress' that contains the whole address. I want to select those records where the (house number) concat (stree number) concat (...) etc. is not the same as the registrant address.

Is this possible in MySQL? or SQL in general?

raf
04-15-2003, 04:44 PM
It probably is possible to some extend, but it will never be bulletproof and i surely wouldn't recommend it.

This sort a controls should be performed before the data (or one part of it) goes into the db.

here, you'll find more info. Look for CONCAT_WS(separator, str1, str2,...)
http://www.mysql.com/doc/en/String_functions.html

So you probably could try to build the value by concatinating the seperate values, and then store it a variable or compare it with another variables value.