ユニオンを使用して複数のクエリを1つの結果セットに結合するmysqlクエリがあります。クエリは完全に機能します。mysql - ユニオンを含むビューを作成できません
私は、エラーメッセージを取得するビューを作成するために、同じクエリを使用したい:完璧に動作
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
私のクエリは次のとおりです。
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
私ビューを作成するクエリは次のとおりです。
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)
は
これはphpMyAdminの中に以下のエラーが発生します。何の書式設定や照合の問題があってはならないので
クエリがひどく設計されたテーブルからすべてです。ユニオンクエリに対してビューを作成できますか?
アドバイスありがとうございます。
は素晴らしい週末を持って、 ライアン
すべてのSELECTクエリは同じ条件 - 'hulaminloadnumber1> 0'を持ちます。それが正しいか? – Devart
こんにちは@Devart、あなたは間違って、悪いコードをコピー申し訳ありません。質問を修正します。ただし、正しいコードで同じエラーが発生します。 – Smudger
ありがとうございました - エラーについて - Ashwinの答えを見てください。それはそれを修正します。 – Devart