Skip to content
Advertisement

Return in which or statement results are from SQL [closed]

I’m having the following SQL statement, to return worksheets that teachers have liked, and worksheets that teachers made by themselves.

It’s working fine, but now I also want to return if the worksheet was liked, or made by the teacher. How do I do that? I tried things with an if statement, but could not figure out a working solution.

Advertisement

Answer

How about a left join and conditional logic?

This puts the “made or like” information in two different columns (after all, a teacher could have made and liked a worksheek).

OR sometimes kills performance. union all might be more efficient:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement