Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - Multiple clauses on JOIN?

Tags:

sql

Let me post my database structures first. Table: monsterdata - http://prntscr.com/92eet Table: user_team - http://prntscr.com/92eef

I want data in user_team(m1,m2,m3,m4,m5,m6) to be matched with monsterdata.id so that I can retrieve other info. What I managed to do was retrieve only one data

    SELECT * FROM monsterdata LEFT JOIN user_team ON monsterdata.id=user_team.m1

But what I really want to do is, to include m2,m3,m4,m5,m6 to monsterdata.id=user_team.X

This might be silly but I'm more silly not to figure how to do this. Thanks for the help!

like image 939
Sharks Sri Avatar asked Jan 17 '23 17:01

Sharks Sri


1 Answers

    SELECT * 
    FROM monsterdata LEFT JOIN user_team 
    ON monsterdata.id=user_team.m1 AND/OR 
    monsterdata.id=user_team.m2 AND/OR ...

There you go!

like image 199
Tushar Avatar answered Jan 26 '23 00:01

Tushar