问题标签 [concat-ws]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
109 浏览

mysql - group_concat uses wrong delimiter

this is a part of my query:

I have following problem: if first_name and last_name exist everything works fine, persons are separated with ', ' and there is a space between first and last name.

But: if first_name is NULL the next person is separated with ' ' (space) from concat_ws and not with ', ' as it should

0 投票
1 回答
48 浏览

mysql - 将 MySQL 密钥对转换为连接列表

我有 3 张桌子:

第三张桌子是多对多的,PRIMARY KEY那对有一张。

我正在尝试创建一个类似于以下内容的视图:

这是我正在尝试的

但我收到此错误:

0 投票
2 回答
48 浏览

mysql - 如何将记录集限制为过去的日期

第二次尝试这个,我就是不明白。

我想删除毕业日期已过的毕业生 vs $today 所以我想将记录集限制为仅在数据库中的日期是过去的那些。

我的表将 gradMonth 和 gradYear 存储为 varchar,即 2013 年 6 月。

所以,$today = strtotime(date("Y-F"))。这可以按预期工作并产生 1378008000 。

我想连接 gradMonth,gradYear 的表字段值并将它们与$today. 所以我的查询是:

奇怪的是,这始终包括 2014 年 10 月和其他不小于 $today 的月份的记录,我不知道为什么。

感谢您提供的任何想法或帮助。

0 投票
2 回答
244 浏览

mysql - 如果 MySQL CONCAT_WS 中的所有值都为 NULL,如何删除分隔符?

我正在尝试使用 CONCAT_WS 生成主题行。但是,如果值为空,我想忽略分隔符。

请看这个查询

问题是当“program_name”为 NULL 时,字符串末尾总是会出现“-”。我不想连接“-” id program_name IS NULL

我怎么做?

谢谢

0 投票
1 回答
722 浏览

mysql - JPQL 中有 CONCAT_WS 方法吗?

我想知道是否有类似我在这里找到的CONCAT_WS方法:JPQLMYSQL documentation

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws

有人偶然发现过类似的东西吗?

0 投票
1 回答
55 浏览

php - 基于初始查询结果的 MySql 查询中的新查询

我正在尝试从一个表(“SP_Cont”)中获取联系信息,然后根据县代码(CID)从“Counties”表中获取实际的县名称(“CTitle”)。

我想要实现的是一个看起来像这样的地址......

地址 1、地址 2、地址 3、城市、县、邮政编码。

我知道上面不会这样做,但至少我不必像现在这样在 PHP 页面中运行另一个查询来添加县:

所以它看起来像这样:

地址 1、地址 2、地址 3、城市、邮政编码、县。

有没有办法获得所需的地址格式

地址 1、地址 2、地址 3、城市、县、邮政编码。?

另一个问题是如果 SP_Cont 不包含 CID 代码,则脚本将失败。无论如何使用 CONCAT_WS 如果有一个 NULL CID 脚本仍然运行,但没有县标题?

干杯

0 投票
1 回答
724 浏览

sql - Distinct in a wm_concat in oracle

I made a query that get all rooms with its name, its address, and other data.

Too long for all the data, the only one important data are the name and the address.

The fact is, 2 rooms can have the same address, so in result I don't want :

room1 address1 - room2 address1

that, I actually get, but

room1 address1 - room2 at the same address

is this possible in oracle 10?

I tried adding a distinct for the address field, but of course not possible.

Thank you.

0 投票
2 回答
595 浏览

mysql - MySQL 特殊字符 concat_ws

我希望以下字符»在我进行查询时显示,但我不断收到以下字符»

这是我的查询:

我的数据库设置为 utf8_general_ci

0 投票
1 回答
825 浏览

mysql - MYSQL CONCAT_WS 和 UNIX_TIMESTAMP

您好,我有日期和时间表:

我会这样做:

稍后我输入以下代码:

我想收集两个查询。我想newtime放入 unix 时间戳查询。

谢谢

0 投票
1 回答
113 浏览

mysql - 使用 CONCAT_WS 错误更新表

我有 2 个名为 vhistory 和 week2 的表。vhistory 包括两个列 voternum 和 voterhistory。week2 包含列 age、address、voternum、voterhistory、status、gender、precinct、county 和 zip5。我需要使用表 vhistory 更新 week2 voterhistory,其中 week2 voternum = vhistory voternum。

例如:
在第 2 周内,有一个人的 voternum = 1234。在 vhistory 中有 3 条记录,其中 voternum = 1234。一个有一个 voterhistory = 2011,一个有一个 voterhistory = 2012,一个有一个 voterhistory = 2013。这意味着当更新 week2 的 3 条 vhistory 记录应导入 week2 表的 voterhistory 列,如下所示:2011、2012、2013。

这就是我到目前为止所拥有的。