假设我有两个表,table_neo 和table_two
table_neo结构
table_neo的数据
table_two的结构
table_two的数据
我的查询语句是这样写的
SELECT
table_one.username
FROM
table_one
INNER JOIN table_two ON table_one.id=table_two.table_one_id
WHERE
table_one.lastname LIKE "%张%"
OR table_one.nickname LIKE "%张%"
OR table_one.username LIKE "%张%"
OR table_two.lastname LIKE "%张%"
OR table_two.nickname LIKE "%张%"
OR table_two.username LIKE "%张%"
这样查出来是空的 原因是因为table_two里面没有与table_neo相关联的数据
我想要的效果是 table_two里面的数据如果有的话就匹配 如果没有的话就忽略,把table_neo里面匹配到的数据查出来
这种效果是否能实现 如果能实现又如何用sqlalchemy来写