例子如下:
        select * 
        from  tab1  a   
        join tab2  b on a.col < b.col
习惯了等值连接,我该如何理解sql中的大于小于号呢,求大大们开导:)

解决方案 »

  1.   

    a.col和所有小于b.col的值进行连接
      

  2.   

    a
    1
    5b
    3
    4a=1时,B有3、4条记录
    a=5时,没有记录
      

  3.   


    如果a.col 为1-100,b.col为1-100,他们大致会产生5050条数据。
    而等值情况下只有100条条数据。
    是这样吗?
      

  4.   

    rucupli大大  小的还有问题,如果使用left join 的话  mysql 产生了如下sql:
    select `a`.`soft_id` AS `soft_id` 
    from `t_app_info` `a` 
    left join `t_app_info` `b` on((`a`.`soft_id` < `b`.`soft_id`))
    where 1 这个应该怎么看 (`a`.`soft_id` < `b`.`soft_id`) 和 where 1   呢?原sql:
    select a.soft_id
    FROM t_app_info a 
    left JOIN t_app_info b on a.soft_id < b.soft_id;
      

  5.   


    后来发现  mysql是先进行两表笛卡尔积,然后将 a.col < b.col  作为条件 写在where中,sql如下:select `a`.`soft_id` AS `soft_id` 
    from `t_app_info` `a` 
    join `t_app_info` `b`
    where `a`.`soft_id` < `b`.`soft_id`;
     
      

  6.   

    用tab1中的每条记录都和tab2中的每条记录进行比较。