Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

mysql select kako pridodati vrijednost

[es] :: MySQL :: mysql select kako pridodati vrijednost

[ Pregleda: 2413 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Keyframe
Keyframe
Zagreb

Član broj: 96054
Poruke: 14
*.adsl.net.t-com.hr.



Profil

icon mysql select kako pridodati vrijednost04.07.2006. u 13:36 - pre 216 meseci
ako se moze napraviti query SELECT 2+2, i izbaci field 2+2 sa vrijednosti 4

pa ako se moze i recimo SELECT foo+1 FROM table, ako je foo int - pa pridoda 1 svim intovima

kako napraviti da ako je foo text field, da se pridoda vrijednost na pocetak ili na kraj fielda.. nesto tipa SELECT 'pretekst'+foo+'posttekst' FROM table - naravno, ovaj query ne radi
 
Odgovor na temu

NikolaVeber
NikolaVeber
neradnik na porodiljskom bolovanju
Karlsruhe

Član broj: 5115
Poruke: 1254
*.sap-ag.de.

Jabber: nikolaveber@jabber.org
ICQ: 121532865


Profil

icon Re: mysql select kako pridodati vrijednost04.07.2006. u 14:06 - pre 216 meseci
Citat:
#

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'

#

CONCAT_WS(separator,str1,str2,...)

CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.

mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name');
-> 'First name,Second name,Last Name'
mysql> SELECT CONCAT_WS(',','First name',NULL,'Last Name');
-> 'First name,Last Name'

CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.

Pop Servis "Paradise Tours"
Java User Group Karlsruhe
IT Dan - Srbija

Officer, I saw the driver who hit me - his name was Johnny Walker.
 
Odgovor na temu

Keyframe
Keyframe
Zagreb

Član broj: 96054
Poruke: 14
*.adsl.net.t-com.hr.



Profil

icon Re: mysql select kako pridodati vrijednost04.07.2006. u 14:11 - pre 216 meseci
to care, puno hvala!
 
Odgovor na temu

[es] :: MySQL :: mysql select kako pridodati vrijednost

[ Pregleda: 2413 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.