关系数据库简单搜索字符串
嘿伙计们, 这是我之前提出的问题的后续。这是我第一次使用关系数据库,我需要快速搜索字符串的帮助来得出所需的结果。
背景信息:我正在为我的照片组合创建一个数据库,并希望能够通过其类别检索图像链接/数据。每个图像可以在多个类别中列出。
我的数据库设置如下:
表tbl_images
(image_id
,image_title
,image_location
,image_descrip
,image_url
)
表tbl_categories
(category_id
,category_name
,category_descrip
)
TABLE tbl_image_categories
(image_id
,category_id
)
其中我的一张图像 (image_id=1) 有两个类别(沙漠 [category_id=1] 和冬天 [category_id=2])。我在 tbl_image_categories 中将其定义为 1,1 和 1,2。
我还有一些其他图像被定义为沙漠图像 [category_id=1]。
我将如何根据沙漠类别获取应加载的图像?
我试过:
SELECT tbl_images.image_url
FROM tbl_images,
tbl_image_categories,
tbl_categories
WHERE tbl_categories.category_id = 1
Hey guys,
This is a follow-up to a question that I asked earlier. It is my first time using a relational database and I need help with a quick search string to bring up desired results.
Background information: I'm making a database for my photo portfolio and want to be able to retrieve image links/data via their categories. Each image can be listed in multiple categories.
My database is set-up as follows :
TABLE tbl_images
(image_id
, image_title
, image_location
, image_descrip
,image_url
)
TABLE tbl_categories
(category_id
,category_name
,category_descrip
)
TABLE tbl_image_categories
(image_id
,category_id
)
Where one of my images (image_id=1) has two categories (Desert [category_id=1] and Winter [category_id=2]). Which I defined in tbl_image_categories as 1,1 and 1,2.
I also have a few other images that I defined as Desert images [category_id=1].
How would I go about getting which images should be loaded based on the Desert Category?
I tried:
SELECT tbl_images.image_url
FROM tbl_images,
tbl_image_categories,
tbl_categories
WHERE tbl_categories.category_id = 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: