Mam kwerendę mysql, która używa union do łączenia wielu kwerend w jeden zestaw wyników. zapytanie działa idealnie.mysql - nie można utworzyć widoku, który zawiera związek
Kiedy chcę używać tego samego zapytania do utworzenia widoku I wtedy pojawia się komunikat o błędzie:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union select hulaminloadnumber2,deliveryid,drop1customer from localjhb where hul' at line 2
moje zapytanie, które działa idealnie brzmi:
select hulaminloadnumber1,deliveryid,drop1customer from localjhb where hulaminloadnumber1>0
union
select hulaminloadnumber2,deliveryid,drop1customer from localjhb where hulaminloadnumber2>0
union
select hulaminloadnumber3,deliveryid,drop1customer from localjhb where hulaminloadnumber3>0
union
select hulaminloadnumber4,deliveryid,drop1customer from localjhb where hulaminloadnumber4>0
union
select hulaminloadnumber5,deliveryid,drop1customer from localjhb where hulaminloadnumber5>0
mój zapytanie do utworzenia widoku to:
create view View_LoadvsCustomer as (
select hulaminloadnumber1,deliveryid,drop1customer from localjhb where hulaminloadnumber1>0
union
select hulaminloadnumber2,deliveryid,drop1customer from localjhb where hulaminloadnumber2>0
union
select hulaminloadnumber3,deliveryid,drop1customer from localjhb where hulaminloadnumber3>0
union
select hulaminloadnumber4,deliveryid,drop1customer from localjhb where hulaminloadnumber4>0
union
select hulaminloadnumber5,deliveryid,drop1customer from localjhb where hulaminloadnumber5>0)
ten wytwarza poniżej błąd w phpMyAdmin:
Zapytania są ze źle zaprojektowanym stole, więc nie powinno być żadnych problemów formatowania lub sortowania. Czy można utworzyć widok dla kwerendy związanej?
Każda rada jest doceniana.
Miłego weekendu, Ryan
Wszystkie zapytania SELECT mają ten sam warunek - 'hulaminloadnumber1> 0'. Czy to jest poprawne? – Devart
Witaj @Devart, masz rację, przykro mi kopie błędnego kodu. poprawi pytanie. Ten sam błąd występuje jednak przy poprawnym kodzie. Dziękujemy – Smudger
O błędzie - spójrz na odpowiedź Ashwina A. Naprawi to. – Devart