Home  >  Article  >  Backend Development  >  如何处理在数据库中使用联合操作

如何处理在数据库中使用联合操作

WBOY
WBOYOriginal
2016-06-13 13:33:48914browse

如何避免在数据库中使用联合操作
有三个表:
user表:

id name
1 kiven
2 martin
3 tina

user_class表:

user_id class_id
1 1
2 1
3 2

class表:

id name
1 php
2 java
3 .net


我想要输出一个表格,是这样结构的:
user_name class_name
kiven php
martin php
tina java


不用join联合查询,应该怎么做?
先谢谢各位了。

------解决方案--------------------
那你就把数据放在一张表里就是了
但不要说冗余太多
------解决方案--------------------
文章里面的例子与你的情况不符合,不能拿来比较,想减少数据库负担那就扩展字段
#6的联合查询虽然没用join,但效率还比不上join

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn