09-11-2006, 21:27
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
כשאת עושה +, את למעשה מחברת בצורה מתמטית את המחרוזות מה שלבסוף יוצא מספר.
כדי להימנע מזה ופשוט לחבר את המחרוזות, תשתמשי בפונקציה CONCAT (יש מצב שתיצטרכי להיעזר ב-CAST).
ראי בעמוד הזה:
http://dev.mysql.com/doc/refman/5.0...-functions.html
זה נמצא באיזור למעלה...
הפיסקה היא:
ציטוט:
CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
SELECT CONCAT(CAST(int_col AS CHAR), char_col);
CONCAT() returns NULL if any argument is NULL.
mysql> SELECT CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT CONCAT('My', NULL, 'QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> '14.3'
|
|