Creating MySQL View using UNION

后端 未结 5 1844
逝去的感伤
逝去的感伤 2021-02-14 06:18

I am trying to create a view for the following query.

SELECT DISTINCT
  products.pid        AS id,
  products.pname      AS name,
  products.p_desc     AS descri         


        
5条回答
  •  春和景丽
    2021-02-14 06:41

    The error message is in "QueryBrowser.pas", part of mysql-gui-tools.

    procedure TQueryBrowserForm.SQLCreateViewClick(Sender: TObject);
    // ... 
    begin
      if Assigned(ActiveResultset) and (ActiveResultset.ResultSet.query.query_type = MYX_QT_SELECT)then
        // ... 
      else
        ShowError('Creation error', _('A view can only be created from a active resultset of SELECT command.'), []);
    end;
    

    It is triggered by a) not having an active result set and b) the query having the wrong type.

    Does removing the "DISTINCT" make any difference? In any case, this is a bug in QueryBrowser, rather than one MySQL. Creating the view directly in MySQL should suffice as a work-around.

提交回复
热议问题