簡體   English   中英

我應該怎么做才能根據條件加入 2 個表?

[英]What should I do to join 2 tables based on a condition?

我想加入 2 個表: book_details imdb_index is >=600;的書籍的 book_details 和imdb_index

在此處輸入圖像描述

這是我嘗試過的:

select *from imdb_index where imdb_index>=600 as x join book_details as y on x.isbn=y.isbn;
SELECT * FROM imdb_index AS x JOIN book_details AS y ON x.isbn = y.isbn 
WHERE x.imdb_index>=600;

有關加入的更多詳細信息,請訪問https://www.mysqltutorial.org/mysql-join/

where 和 join 子句放錯了地方

    select * 
    from imdb_index x 
    join book_details y on x.isbn=y.isbn
    where y.imdb_index>=600  ;

join 子句必須在 where 子句之前

通過使用以下查詢,您將能夠從 imdb_index >=600 的表中獲取數據。

   select * 
   from imdb_index as im 
   join book_details as bd
   on im.isbn = bd.isbn 
   where im.imdb_index>=600;

您在join之前使用where條件。您應該先Join ,然后才應該使用where

強烈建議閱讀和觀看一些關於joins的教程。

以下鏈接將對您有所幫助。

1. https://www.w3schools.com/sql/sql_join.asp

2. https://dev.mysql.com/doc/refman/8.0/en/join.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM