I have, for example, the following scenario:
Table Column01 Column02 Column03 Home book id name genre Home captl id name content Home cplivro id idcap id book
When I have to associate a book with a chapter I use the cplivro
table by putting the id
of the book and the id
of the chapter.
When for example I have the book with id 1
and I want to find the capitúlos of it I do 'two' SELECT
:
- First fetching all records in
cplivro
whereidlivro
is equal to 1. - Second in a for searching in the captl table an element of
array
resulting from the firstSELECT
Is it advantageous to do so? I tried to search a little bit and I think UNION
would serve this, but I could not understand, what would it be like UNION
?