有两个表,第一个booking,
字段o_id(订单号),o_user(用户ID),o_time(订单时间),o_state(订单状态),o_delivery,o_ems,o_number,o_total第二个表information,
字段i_id(订单详细信息ID),i_orderid(订单号,外键),i_name(物品名字),i_number,i_price其中information表中的i_orderid是booking表中o_id的外键
现在我有个一个$uid存放用户ID,我想查找这个ID的两个表中的所有信息,怎么写?

解决方案 »

  1.   

    select a.*, b.* from booking a, information b where a.o_id = b.i_orderid and a.o_user = $uid关联一下就差不多了
      

  2.   

    select *
    from booking a inner join information b on a.o_id=b.i_orderid
    where o_user=$uid
      

  3.   

    select a.*, b.* from booking a, information b 
    where a.o_id = b.i_orderid 
    and a.o_user = $uid
      

  4.   

    select a.*, b.* from booking a, information b 
    where a.o_id = b.i_orderid 
    and a.o_user = $uid