dongzuan4491
dongzuan4491
2017-08-25 16:50

使用uuid Json的PHP MYSQL链接数组

已采纳

First of all, I'm happy to see people helping people here :D.

I got also a small issue sadly,

DB 1 contains: UUID and much values.

DB 2 contains: UUID and again many other values.

what I want is

[0] => Array
        (
            [UUID] => 96
            [DB1 values]
            [DB2 values] 
        )

i thought that will work with array_combine but that isn't true sadly because then i miss some db1 values

here database images:

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dtc4547 dtc4547 4年前

    --EDIT-- Your picture helped. You can handle that at the SQL Level

    SELECT Login.*, Location.*
    FROM Login
    LEFT JOIN Location ON Login.UUID=Location.UUID
    GROUP BY Login.UUID
    

    Then the resulting data in PHP will already be correctly formatted. Notice that I chose table Login to drive the query, could have also chosen the Location table. depends on the underlying structure

    点赞 评论 复制链接分享