gpt4 book ai didi

php mysql查询出所有单词,但不重复

转载 作者:行者123 更新时间:2023-11-29 04:29:00 25 4
gpt4 key购买 nike

对不起,我没有用英语提出明确的问题。

我需要这样的 mysql 查询:通过两个表查询出所有项目名称,UNION,但不重复。

这是我的表结构:

表:cxt_20110105

item         | ... many columns, but does not affect query, because I just need item.
art |
collectibles |
furniture |
books |
arts |
books |
... many lines...

表:cxt_20110106

item         | ... many columns, the columns structure is as well as table: cxt_20110105.
art |
tickets |
cars |
furniture |
tickets |
cars |
... many lines...

所以

mysql_query(//how to write in here?)
while ($row = mysql_fetch_array($result))
{
//the result should be: art, collectibles, furniture, books, tickets, cars(every word, but not repeat) ;
}

谢谢。

最佳答案

SELECT item FROM cxt_20110105

UNION DISTINCT <---the important bit.

SELECT item FROM cxt_20110106

关于php mysql查询出所有单词,但不重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com