以下のSQLクエリは、必要なデータを返していますが、組織の "支払い状況"、 "支払い待ち"と "有料"の表の列に返されます。支払い状況(有料/未払い)は上記のものではなく企業向けに返されます。SQLクエリとエラー無効な列名から特定のデータを返します
私は、これは支払い状況は唯一の「有料」AND「未払い」に等しいwhere句であるかもしれないことを考えていた、私はこれを実行しようとしましたし、私は PAYMENT_STATUS
エラー無効な列名を持っていました
は
SELECT Account.mm_registrationnumber AS CL_Reg_Number, Account.Name, Account.mm_supplierstatus AS Supplier_Status, Account.PrimaryContactIdName AS Primary_Contact, Account.EMailAddress1 AS Email, Account.Telephone1 AS Telephone, mm_address.mm_line1 AS Line1, mm_address.mm_line2 AS Line2, mm_address.mm_line3 AS Line3, mm_address.mm_line4 AS Line4, mm_address.mm_city AS City, mm_address.mm_county AS County, mm_address.mm_postcode AS Postcode, mm_turnover.mm_name AS Signup_Turnover, Account.mm_signupdate AS SignUp_Date, mm_payment.mm_paymenttype AS Payment_Type, mm_payment.mm_paymentstatus AS Payment_Status, mm_payment.mm_vatamount AS Payment_Amount_VAT, mm_payment.mm_paymentamount AS Payment_Amount_Net, Invoice.InvoiceNumber AS Invoice_ID, Invoice.DueDate AS Due_Date, Invoice.CreatedOn AS Created_Date FROM Account INNER JOIN mm_payment ON mm_payment.mm_organisation = Account.AccountId INNER JOIN mm_address ON Account.mm_address = mm_address.mm_addressId INNER JOIN mm_turnover ON Account.mm_turnover = mm_turnover.mm_turnoverId INNER JOIN Invoice ON Invoice.AccountId = Account.AccountId WHERE Payment_Status = 'Paid'; // error 'invalid column name Payment_Status'
mm_payment.mm_paymentstatus' – Sariful
SQLは、様々な条項という点で、かなり混乱した言語であるWHERE '試してみてください'SELECT'は明らかな(初心者の)順序では処理されません。ここにはSQL Server [ドキュメント](https://docs.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql#logical-processing-order-of-the-select-文) –