*Ralat Oracle ORA-00918: Menyelesaikan Lajur Kabur dalam PILIH Penyata**
Melaksanakan pertanyaan SELECT *
yang melibatkan berbilang jadual dengan lajur yang dinamakan sama sering mengakibatkan ralat ORA-00918: "lajur ditakrifkan secara samar-samar." Kekaburan ini timbul kerana pangkalan data tidak dapat menentukan lajur jadual mana yang hendak diambil apabila berbilang jadual berkongsi nama lajur.
Pertimbangkan contoh ini:
<code class="language-sql">SELECT * FROM (SELECT DISTINCT(coaches.id), people.*, users.*, coaches.* FROM "COACHES" INNER JOIN people ON people.id = coaches.person_id INNER JOIN users ON coaches.person_id = users.person_id LEFT OUTER JOIN organizations_users ON organizations_users.user_id = users.id ) WHERE rownum <p>To correct this, replace the ambiguous `SELECT *` with a specific column selection. For instance:</p><p>Instead of selecting all columns (`SELECT *`), explicitly list the desired columns and use aliases to resolve ambiguity:</p>SELECT coaches.id AS COACHES_ID, people.name, users.email, coaches.team FROM ... -- Rest of your query remains the same This approach assigns unique aliases (e.g., `COACHES_ID`) to each selected column, eliminating the ambiguity. Alternatively, omit duplicate columns entirely, selecting only the necessary data. Best practice dictates avoiding `SELECT *` in production SQL. Explicitly defining columns enhances code clarity, maintainability, and reduces the risk of errors caused by ambiguous column names.</code>
Atas ialah kandungan terperinci Bagaimana untuk Menyelesaikan ORA-00918: 'lajur ditakrifkan secara samar-samar' dalam SQL SELECT * Pertanyaan?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!