开发者

Mysql select/join?

Earlier I was taught how to select and concat in a query (Used that to add some text to some image urls).

However, I am quite stumped now. The next thing I need to tackle is "grabbing" each individual cards url. Unfortunately the url is not stored in the database, instead it is made up by pulling the corresponding category, sub category, and then the cards name.

I know to use

select name from cards

but then after that I am pretty much lost.

There are 3 main tables I have narrowed it down to.

  1. Card_categories contains category_id_card_id, card_category_id.
  2. Categories contain category_id, name.
  3. Cards contains card_id and other card related information.

I do know the url structure needs to be www.a开发者_运维百科myadele.com/name(category)/sub category/name (from cards)


select
  concat('www.amydale.com/', mc.name, '/', sc.name, '/', c.name) as url
from
  cards c
  inner join subcategory sc on sc.subcategoryid = c.subcategoryid
  inner join category mc on mc.categoryid = sc.categoryid


Perhaps reading up on the JOIN examples would help you: http://mysqljoin.com/joins/inner-join-tutorial/


yes - read up on JOINS, then look up 'CONCATENATION'

you can 'grab' all the values, and append them to each other as one single string result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜