打扰一下,我没有用英文提出一个明确的问题。php mysql查询出所有的单词,但不重复
我需要一些像这样的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) ;
}
感谢。
从[mysql文档](http://dev.mysql.com/doc/refman/5.0/en/union.html):“UNION的默认行为是重复的行从结果中删除。可选的DISTINCT关键字除默认外没有任何作用,因为它还指定重复行删除。“ – 2011-05-13 21:01:22
我更喜欢写明确的查询,以明确发生了什么。默认值是好的,但看到这样拼写出来就会让其他人更清楚。 – 2011-05-13 21:06:46
正确,DISTINCT没有用。答案很简单。我没有很好地学习基础知识。谢谢。 – cj333 2011-05-13 21:07:37