将sql的相同结果绑定为一个字符串

时间:2022-09-20 07:39:08

How to bind the same results of MySQLi query as one string. Like I have column "visitor_country" which contains country codes of visitors. I have 5 columns of PK and 5 columns of AU. I want to echo them in my web page. How can i group same country codes? and display like:

如何将MySQLi查询的相同结果绑定为一个字符串。就像我有列“visitor_country”,其中包含访问者的国家/地区代码。我有5列PK和5列AU。我想在我的网页上回应它们。我如何分组相同的国家/地区代码?并显示如下:

   |PK 5|
   |AU 5|

this is my database table 将sql的相同结果绑定为一个字符串

这是我的数据库表

I want to get all the country codes from visitor_country and bind all same country codes and echo them

我想从visitor_country获取所有国家/地区代码并绑定所有相同的国家/地区代码并回显它们

1 个解决方案

#1


1  

You'd probably want to take a look at MySQL's GROUP BY function

你可能想看一下MySQL的GROUP BY函数

SELECT `visitor_country` FROM `tablename` GROUP BY `visitor_country`;

This really should do the trick: take a look at this example

这真的应该做的伎俩:看看这个例子

#1


1  

You'd probably want to take a look at MySQL's GROUP BY function

你可能想看一下MySQL的GROUP BY函数

SELECT `visitor_country` FROM `tablename` GROUP BY `visitor_country`;

This really should do the trick: take a look at this example

这真的应该做的伎俩:看看这个例子