简体   繁体   English

是否有任何SQL或MySQL查询以句子的形式显示所有数据?

[英]Is there any SQL or MySQL query to display all the data in a form of a sentence?

I want to display the data in a sentence like "SMITH HAS HELD THE POSITION OF CLERK IN DEPT 20 FROM 1981".我想用“SMITH HAS HELD THE POSITION OF CERK IN DEPT 20 FROM 1981”这样的句子来显示数据。 How can i do this in MySQL ??我怎样才能在 MySQL 中做到这一点? Where I'll retrieve the name , job , hiredate and dept no.我将在哪里检索姓名、工作、聘用和部门编号。 from the table And sorry I'm totally new to stack overflow从表中 对不起,我是堆栈溢出的新手

You need to use CONCAT() function to create a sentence using different values from a table column.您需要使用 CONCAT() 函数来使用表列中的不同值创建一个句子。 for eg.例如。

SELECT
concat(upper(name)," HAS HELD THE POSITION OF ",upper(job)," IN DEPT ",deptno," FROM ",year(hiredate)) as EmployeeInfo
FROM tbl;

DEMO演示

you can change the query according to your requirement (as you did not provide any data we are can't provide exact query).您可以根据您的要求更改查询(因为您没有提供任何数据,我们无法提供准确的查询)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM