是否可以在MySQL的视图表上创建自动增量列?
CREATE view `product_auction`
AS
SELECT
Concat(IF(( ( `product_0`.`category_1` = '' )
OR ( `product_0`.`category_1` = '0' )
OR ( `product_0`.`category_1` = NULL ) ), 'Category 0 Empty<br/>',
''),
IF(( ( `product_0`.`category_1` = '' )
OR ( `product_0`.`category_1` = '0' )
OR
Isnull(`product_0`.`category_1`) ), 'Category 1 Empty<br/>', ''), IF(( ( `product_0`.`category_2` = '' )
OR ( `product_0`.`category_2` = '0' )
OR Isnull(`product_0`.`category_2`) ), 'Category 2 Empty<br/>', ''),
IF(( ( LEFT(`product_transfer`.`code`, 1) = 1 )
OR ( LEFT(`product_transfer`.`code`, 1) = 2 ) ),
IF((
( `product_0`.`minimum_price` = '' )
OR (
`product_0`.`minimum_price` = '0' )
OR
Isnull(
`product_0`.`minimum_price`) ), 'Start Price Empty<br/>', ''), ''), IF(( ( LEFT(`product_transfer`.`code`, 1) = 1 )
OR ( LEFT(`product_transfer`.`code`, 1) = 2 ) ),
IF(( ( `product_0`.`eastimated_price` = '' )
OR ( `product_0`.`eastimated_price` = '0' )
OR ( `product_0`.`eastimated_price` = NULL )
OR
Isnull(`product_0`.`eastimated_price`) ), 'Estimated Price Empty<br/>', ''), ''),
IF(( LEFT(`product_transfer`.`code`, 1) = 3 ), IF(( (
`product_0`.`eshop_price` = '' )
OR (
`product_0`.`eshop_price` = '0' )
OR
Isnull(
`product_0`.`eshop_price`) ), 'EStore Price Empty<br/>', ''), ''), IF(( ( `product_0`.`category_0` = '' )
OR ( `product_0`.`category_0` = '0' )
OR
Isnull(`product_0`.`category_0`) ), 'Head Category_0 Empty<br/>,', ''), IF(( ( `product_0`.`title` = '' )
OR ( `product_0`.`title` = '0' )
OR Isnull(`product_0`.`title`) ), 'Title Empty<br/>', ''),
IF(( ( `product_0`.`shipping_local` = '' )
OR ( `product_0`.`shipping_local` = '0' )
OR
Isnull(`product_0`.`shipping_local`) ), 'Shipping Local Empty<br/>', ''), IF(( ( `product_0`.`shipping_abroad` = '' )
OR ( `product_0`.`shipping_abroad` = '0' )
OR
Isnull(`product_0`.`shipping_abroad`) ), 'Shipping Abroad Empty<br/>', ''), IF(( ( `product_0`.`images` = '' )
OR ( `product_0`.`images` = '0' )
OR Isnull(`product_0`.`images`) ), 'Image(s) Empty', '')) AS `error`,
`product_0`.`id` AS `id`,
`product_0`.`cn_sl_no` AS `cn_sl_no`,
`product_transfer`.`code` AS `code`,
`product_transfer`.`unix_time` AS `unix_time`,
From_unixtime(`product_transfer`.`unix_time`) AS `end_time`,
`category_hp`.`category` AS `Cat_HP_text`,
`product_0`.`category_hp` AS `category_hp`,
`product_0`.`category_1` AS `category_1`,
`product_0`.`category_2` AS `category_2`,
`product_0`.`category_3` AS `category_3`,
`product_0`.`category_4` AS `category_4`,
`product_0`.`category_0` AS `category_0`,
`product_0`.`title` AS `title`,
`product_0`.`quantity` AS `quantity`,
`product_0`.`size` AS `size`,
`product_0`.`size_width` AS `size_width`,
`product_0`.`size_actual` AS `size_actual`,
`product_0`.`weight` AS `weight`,
`product_0`.`quality` AS `quality`,
`product_0`.`expert` AS `expert`,
`product_0`.`minimum_price` AS `minimum_price`,
`product_0`.`reserve_price` AS `reserve_price`,
`product_0`.`eastimated_price` AS `eastimated_price`,
`product_0`.`eshop_price` AS `eshop_price`,
`product_0`.`discount_price` AS `discount_price`,
`product_0`.`description` AS `description`,
`product_0`.`d_01_head` AS `d_01_head`,
`product_0`.`description_01` AS `description_01`,
`product_0`.`d_02_head` AS `d_02_head`,
`product_0`.`description_02` AS `description_02`,
`product_0`.`d_03_head` AS `d_03_head`,
`product_0`.`description_03` AS `description_03`,
`product_0`.`d_04_head` AS `d_04_head`,
`product_0`.`description_04` AS `description_04`,
`product_0`.`d_05_head` AS `d_05_head`,
`product_0`.`description_05` AS `description_05`,
`product_0`.`d_06_head` AS `d_06_head`,
`product_0`.`description_06` AS `description_06`,
`product_0`.`d_07_head` AS `d_07_head`,
`product_0`.`description_07` AS `description_07`,
`product_0`.`d_08_head` AS `d_08_head`,
`product_0`.`description_08` AS `description_08`,
`product_0`.`shipping_local` AS `shipping_local`,
`product_0`.`shipping_abroad` AS `shipping_abroad`,
`product_0`.`shipping_methord` AS `shipping_methord`,
`product_0`.`reference` AS `reference`,
`product_0`.`status` AS `status`,
`product_0`.`images` AS `images`,
`product_0`.`history` AS `history`,
`product_0`.`operator` AS `operator`,
`product_0`.`datetime` AS `datetime`
FROM ((`product_0`
JOIN `product_transfer`
ON(( ( `product_transfer`.`id` = `product_0`.`id` )
AND ( `product_transfer`.`cn_sl_no` =
`product_0`.`cn_sl_no` ) )))
LEFT JOIN `category_hp`
ON(( `product_0`.`category_hp` = `category_hp`.`id` )))
WHERE ( `product_0`.`status` = 0 );
我要创建自动增量列的视图
答案 0 :(得分:0)
mysql中有row_number函数。但这是从mysql 8.0开始的。
引用:https://www.tutorialspoint.com/what-is-row-number-in-mysql要使它符合product_0.id
之类的列的要求。
您可以看到
SELECT row_number() over ( order by firstName) RowNumberSqeuence,FirstName
from rowNumberDemo order by FirstName;
使用名字顺序的查询确定唯一的row_number。
对于Maria DB,请检查链接:https://mariadb.com/kb/en/library/row_number/ 作为行号功能,如从10.2起的mysql中一样