mysql 加入其他表搜索
SELECT * FROM
companies as C
LEFT JOIN usersSearchCache as UC ON C.id = UC.objectId
WHERE UC.userId = ? AND C.keywords LIKE ?
所以基本上我有一个表:usersSearchCache,它有一个 objectId,objectId 链接到公司表的 id,我需要搜索公司的关键字在用户的缓存中匹配的位置。
上面的查询不起作用,但我不明白为什么。
SELECT * FROM
companies as C
LEFT JOIN usersSearchCache as UC ON C.id = UC.objectId
WHERE UC.userId = ? AND C.keywords LIKE ?
So basically I have an table: usersSearchCache, that has an objectId, the objectId
is linked to the id of the companies table, I need to search where the keywords of the company are matching in the cache of the user.
The query above isn't working but I don't understand why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们在user表中得到了用户,所有这些用户都可以访问对象的页面,当他们访问这些页面时,会在表userSearchCache中创建一条新记录。
返回类似
现在我得到的是一个搜索字段,用户在其中插入他们想要搜索的对象的名称,因此当前的查询是:
要查找“biking”,我会使用 LIKE '%BIKING%'
你的关键字吗参数已包含通配符“%”
We got users in a user table, all those users can visit pages of objects, when they visit these pages, a new records is created in the table userSearchCache.
returns something like
Now what I got is a search field, where the users inserts the name of the object they want to search, so the current query is:
to find "biking", I would use LIKE '%BIKING%'
Does your keyword parameter already contain the wildcard characters '%'