Mysql Join Two tables on keys

前端 未结 1 1841
无人共我
无人共我 2020-11-30 15:46

I am trying to join two tables, but seem to be having an issue, The output I am looking for is the amount of rows that there is subjects.

SELECT *
FROM educa         


        
相关标签:
1条回答
  • 2020-11-30 16:23

    First of all, you should normalise your data structure an have a connection table between keys2 and education table.

    To make the join work with the current data structure, use mysql's find_in_set() function:

    SELECT *
    FROM education AS a
    JOIN keys2 AS b on find_in_set(b.`List Idsubjek`,a.`List Idsubjek`)>0 
    WHERE b.`List Idsubjek` IN (52, 54, 55, 67)
    AND `studentid` = '$id'
    
    0 讨论(0)
提交回复
热议问题