Chameera
Chameera

Reputation: 71

mySQL ERROR #1349 View's SELECT contain a sub query in the FROM clause

CREATE VIEW tbloffer_merchant AS ( SELECT MerchantID,ProductCode,OfferID,Visibility,Status,ReplyMessage,ReferenceNumber,Price,Date,RequestID,CompanyName,OverallRating FROM( SELECT * FROM ( SELECT * FROM ( SELECT * FROM tbloffer)AS a NATURAL JOIN tbloffer_product GROUP BY OfferID) AS a NATURAL JOIN ( SELECT ProductCode,MerchantID FROM tblproduct)AS b)As c NATURAL JOIN ( SELECT MerchantID,CompanyName,OverallRating FROM tblmerchant) AS d

Upvotes: 1

Views: 543

Answers (1)

Norbert
Norbert

Reputation: 6084

Yes, too bad MySQL does not allow this. The simple solution is usually to create more views for all your other SELECT statements in the view to prevent all the code between ( )

So a view for:

SELECT ProductCode,MerchantID FROM tblproduct

And one for

SELECT MerchantID,CompanyName,OverallRating FROM tblmerchant

And replace:

SELECT * FROM ( SELECT * FROM tbloffer)

with:

SELECT * FROM tbloffer

Upvotes: 2

Related Questions