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.- Card_categories contains
category_id_card_id
,card_category_id
. - Categories contain
category_id
,name
. - 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.
精彩评论