获取相关项目并将其作为链接输出
table1 :products
具有字段:
products_id
products_price
products_status = 1( In Stock )
products_url
table2 :products_description
具有字段:
products_id(equals products_id in table products )
products_name
我想获取五个相关产品名称(有库存)及其价格,与产品名称的某些部分相匹配。 例如,产品名称为 $product_name
。我想获得五个相关产品名称(有库存)及其价格。
$query = "select products_id , products_price, products_name
from products p
left join products_description pd on p.products_id=pd.products_id and products_status = 1 and ....";`
像这样的匹配:如果产品名称是True Blood Season 1 DVD
,我想显示五个以“True Blood Season”开头的项目。产品名称可能是其他名称。不仅仅是《真爱如血》季节
我如何用 SQL 编写这个?
table1 : products
has the fields:
products_id
products_price
products_status = 1( In Stock )
products_url
table2 : products_description
has the fields:
products_id(equals products_id in table products )
products_name
I want to get five relative products name(in stock) and its price, which matches by some part of the products name.
For example, the product name is $product_name
. I want to get five relative products name(in stock) and its price.
$query = "select products_id , products_price, products_name
from products p
left join products_description pd on p.products_id=pd.products_id and products_status = 1 and ....";`
The match like this: if a product name is True Blood Season 1 DVD
I want to show five items which begin with "True Blood Season ". the products name maybe others. it not only True Blood Season
How do I write this in SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是像上面这样的,但这只是我的想法。
Should be something like the above, but that is just off the top of my head.