search

Home  >  Q&A  >  body text

thinkphp3 joint table query

Take out several pieces of data from a table that satisfy the status value = 2, and then use the IDs of the pieces of data to check other tables.

How to use thinkphp

Not very good at joining table queries

select * from re_deposit where deposit_status = 2

select * from re_client INNER JOIN re_deposit on re_deposit.client_code = re_client.client_code

迷茫迷茫2730 days ago1070

reply all(1)I'll reply

  • 代言

    代言2017-06-07 09:25:28

    select * from re_client INNER JOIN re_deposit on re_deposit.client_code = re_client.client_code
     where re_deposit.deposit_status = 2

    *Note that if two tables have the same fields, the field will only be taken from one of the tables, so it is recommended to add a prefix to the word

    //tp3 is probably written like this

    M("re_client")->join("re_deposit on re_deposit.client_code = re_client.client_code","INNER JOIN")->where("re_deposit.deposit_status = 2")->select(); 

    reply
    0
  • Cancelreply