开发者

sql query to get 2 values in a single field

Suppose I am开发者_JS百科 having table A with 3 fields Name, dob,age

sara 30-sep-1990 20

i need to get an output from select query as

sara,{30-sep-1990:20}

ie 2 values in a single field with braces seperated by colon


Concatenation depends on your DBMS :

MySQL: CONCAT()
Oracle: CONCAT(), ||
SQL Server: +

Example MySQL :

Select Name, CONCAT('{', dob, ':', age, '}')
From A


You don't show schema info (table, column names) or state which database you're using. For oracle:

select '{'||dob||':'||age||'}' from tablename;

For anything else see your database documentation. See the faq: https://stackoverflow.com/faq

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜