there are two tables An and B, both of which are similar in structure.
< hr >A form
< table > < thead > < tr > < th > ID < / th > < th > name < / th > < th > state < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > Zhang San < / td > < td > 0 < / td > < / tr > < tr > < td > 2 < / td > < td > Zhang San 2 < / td > < td > 1 < / td > < / tr > < / tbody > < / table >B form
< table > < thead > < tr > < th > ID < / th > < th > content < / th > < th > UID < / th > < th > state < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > content 1 < / td > < td > 1 < / td > < td > 1 < / td > < / tr > < tr > < td > 2 < / td > < td > content 2 < / td > < td > 2 < / td > < td > 1 < / td > < / tr > < / tbody > < / table > now after the associated query through join
query statement is as follows:
$result = DB::table ("tableA")-> join (" tableB", "tableA.id"," =", "tableB.id")-> get ();
after the query results come out, the contents are aggregated together. The values of state and ID of table An are all overwritten by table B ID and state. How to rewrite