When I am retrieving data from multiple tables in my mySQL database what approach is best to use, joins, unions or view? What are the advantages and disadvantages of each and what circumstances do they suit best?
When I am retrieving data from multiple tables in my mySQL database what approach
Share
That really depends on how you want this data to be displayed.
Joins are used for when you want to select data that is related and display it all in the same row, where Unions are used for appeneding data from two different select statements together.
In your case, a view should be used when you have a very complex query, and you want to simplify the select statement that is needed to select the data. It will make it less confusing if you are going to use the select statement over and over. There are plenty of other reasons to use views, but I do not think they are relavent to this question.