开发者

mysql dynamic var

A little confused how to create a query and set a dynamic var in the query for output.

Lets say I have a basic 开发者_开发百科table with the following

id | name | type | location

Now I want to do a query and select all data pretty simple stuff

SELECT * FROM TABLE

Which will give me ie.

1 | batman | scifi | row a
2 | matrix | scifi | row b

Bit I want to add a dynamic row to tell me its a video. ie

id| name   | type  | location | category
1 | batman | scifi | row a    | video
2 | matrix | scifi | row b    | video

How can I add this to a query ??

Hope someone can advise!!

Thank you in advance


SELECT  *, 
        'video' AS category
FROM    TABLE


SELECT *, 'video' category FROM table

That will add a category column that has a value of video for all rows. Is this what you meant?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜