Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
加入 2 个表的最佳方法是什么,其中第二个表有一个 id 和一个要加入的关键字?
我的尝试:
SELECT id, name FROM table1 LEFT JOIN table2 ON (table1.id = table2.id AND table2.id = 'myKeyword') WHERE ...
有没有办法处理 WHERE 子句中关键字的搜索/连接?
放入 where 子句将table2.id = 'myKeyword'否定LEFT JOIN
table2.id = 'myKeyword'
LEFT JOIN
这是非常合适的,因为你有它。
也许有了更多的细节,我们可以看到你在做什么。
SELECT {column_list} FROM table1 t1, table2 t2 WHERE t1.id = t2.id AND {some_column_from_either_table} = 'myKeyword';