mysql concat function
when i concat($name, $surname)
, is there a way of putting a space in between the $name $surname
using my sql not php so when i get the result it formats a little cleaner?
man开发者_Python百科y thanks
You can concatenate string literals along with your fields, so you can add a space character in a string between the fields you're concatenating.
Use this:
CONCAT(name, " ", surname)
This functionality is documented quite clearly on the MySQL manual page for the CONCAT()
function.
There is also the CONCAT_WS
function which allows you to specify a separator to be used between each of the other fields passed to the function. If you're concatenating more than two fields in the same way, this function might be considered cleaner than repeating the separator between each field.
For example, if you wanted to add a middle name field, you could use this function to specify the separator only once:
CONCAT_WS(" ", first_name, middle_name, surname)
Just add a space in there.
SELECT CONCAT(name,' ',surname) AS full_name FROM table;
EDIT oops, bad spelling there... ;p
Use this, no version dependencies
concat(name,Char(32),venue)
Use CONCAT(name, ' ', surname)
.
after trying this i tried to do this
concat(name, _utf8 ' ' ,name1)
Hey i had the same problem and this is what i used and it really worked out great
CONCAT(column1," ",column2) the issue is you add physical space in between the double courts("") using the space bar on your keyboard and then thats it
The above all options are not working ..
My query is
SELECT CONCAT(FIRSTNAME, ' ' , LASTNAME) AS FULLNAME FROM USERS;
getting the below error:
ORA-00909: invalid number of arguments 00909 00000- "invalid number of arguments" *Cause: *Action: Error at line 26 column :9
精彩评论