Join query with many tables

  • Hi guys,

    I hope everyone's ok

    I have a query in MySql (I'm using Workbench for it) where I'm joining several tables.

    FROM hoursworks TR

    ...

    My 5th join is like this:

    LEFT JOIN pag5_users US

    ON TR.id_ang_user = US.id

    Now I need also to join to the same table and to the same field but from different field from TR...like this

    LEFT JOIN pag5_users US

    ON TR.id_res_puser = US.id

    And it doesn't work. It says "Error Code: 1066. Not unique table/alias:'US'

    Resuming, I have two fields in a table that need to be connected to the same field in another table. Is there a way of doing this?

    Thank you all in advance

     

  • dup post

     
  • LEFT JOIN pag5_users US2

    ON TR.id_res_puser = US2.id

    give it another alias

  • It's amazing this answer!!! So simple!!

    Thank you so much!!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply