I have 3 tables as follows:
Intb_user,Ihavetwotypesofusers(buyer,seller)inanENUMfieldtodifferentiatetheusertype.
IntheshoppingcartIhavetheuserIDs,product,andtransactionnumber.Ilink2timestotb_usuariotoknowwhoboughtandwhosold.
IwanttoperformaSELECTthatbringsthenames(buyer,seller,product),butwhenIdothequeryhappensthefollowingerrors:
1-SELECTtb_user.namethe'buyer',tb_user.namethe'seller',tb_products.namethe'product'FROMpurchases INNERJOINtb_usuarioONcompras.id_comprador=tb_usuario.id_usuario INNERJOINtb_usuarioONcompras.id_vendedor=tb_usuario.id_usuario INNERJOINtb_animaisONcompras.id_produto=productos.id_produtoWherebuy_id=1;
Error:#1066-Notuniquetable/alias:'tb_user'
**DoIneedtocreateatableforeachusertypebecauseofthe2aliases?**
Or
2-SELECTtb_user.namethe'buyer',tb_user.namethe'seller',tb_products.namethe'product'FROMpurchases INNERJOINtb_usuarioONcompras.id_comprador=tb_usuario.id_usuario INNERJOINtb_animaisONcompras.id_produto=productos.id_produtoWherebuy_id=1;
Hereitreturnstwicethesamename(IknowitiswrongbecauseIdonotspecifywhoistheseller).
I do not know if it is necessary to create 3 tables or if there is a way to perform 2 times joining of tb_user with the products. Could you help me?