-1
Good afternoon,I’m having a hard time returning a value from my bank when it has two attributes, I’m starting from this statement.
Select the names of the parts that use the materials with the names "Tamp Round 1m" and "Screw 3cm", (can not appear the part that uses only one of them).
I have this structure of tables
I tried to imagine your sql query to be able to pass to Relational Algebra being this query:
Select * from material_peca AS MP join peca AS P on P.codigop = MP.codigop JOIN material AS M on MP.codigom = M.codigom
where M.nomem = "Tampo Redondo 1m" or M.nomem = "Parafuso 3cm";
However it returns all without exception, but I need it to return only when there are two ways, then tried with a select inside select:
Select * from material_peca AS MP join peca AS P on P.codigop = MP.codigop JOIN material AS M on MP.codigom = M.codigom
where M.nomem = "Tampo Redondo 1m" and (select M.nomem from M where M.nomem = "Parafuso 3cm");
This is an exercise to be able to understand more about Algebra but I can not understand even if you want the bank, if anyone can help me... I did this part in Algebra but I do not know if it is correct:
π nomep ((Σ nomem = Round Top 1m (material_peca |x| material)) (Σ name = Screw (material_peca |x| material)))
At your command there is no reference to the piece with the name "Medium Wooden Shelf" as the exercise asks. You did not enter the meaning of "when there are two ways". In your second SQL command you do not make sense of this AND (sub-select). It would be good for you to post the structure of your tables.
– anonimo
You want to return the name, when nomep is "Medium Wooden Shelf" that?
– Andre Lacomski
I would like to return the nomep when the nomem is "Round Top 1m" and "Screw 3cm"
– DbaAlone
Check if something like this: :Select * from material_peca AS MP Inner Join peca AS P on P.codigop = MP.codigop Inner JOIN material AS M on MP.codigom = M.codigom and (M.nomem = "Round Top 1m" or M.nomem = "Screw 3cm")
– Raquel Andrade
Since your comment above "I would like to return the name when the name is "Round Top 1m" and "Screw 3cm"", I can’t see what its relation to the statement "Select the names of the materials used in the manufacture of the piece with the name "Medium Wooden Shelf"". are two different things
– Raquel Andrade
There is no sense in the phrase "I would like to return the nomep when the nomem is "Round Top 1m" and "Screw 3cm"". A field cannot simultaneously contain 2 values (except for any multivariate attributes, which is not the case).
– anonimo