有三个表:
user表:id    name
1     kiven
2     martin
3     tinauser_class表:user_id    class_id
1          1
2          1
3          2class表:id    name
1     php
2     java
3     .net
我想要输出一个表格,是这样结构的:
user_name    class_name
kiven        php
martin       php
tina         java
不用join联合查询,应该怎么做?
先谢谢各位了。

解决方案 »

  1.   


    看到一篇文章里面有提到这个说法,我也不理解不用联合查询用什么方法,才来问大牛们。
    http://developer.51cto.com/art/201006/204442_2.htm4.在数据库中避免使用联合操作  
      

  2.   

    select a.name,c.name from user a,user_class b,class c where a.id=b.user_id and b.class_id=c.id
      

  3.   

    文章里面的例子与你的情况不符合,不能拿来比较,想减少数据库负担那就扩展字段
    #6的联合查询虽然没用join,但效率还比不上join