MySQL Forums
Forum List  »  InnoDB

Re: Declare a table as like MS SQL Server
Posted by: Peter Brawley
Date: January 04, 2018 05:15PM

You inserted nulls for six of the eight p_nm values, so of course a query on the table returns what was inserted.

Note that since p_nm is varchar, values for it really ought to be quoted.

The stated requirement "227 data should repeat for previous record AND 121 data should repeat for previous records" cannot be reliably implemented because of a fundamental characteristic of relational databases: row content is independent of row order, row order is not a definably persistent table property; row order is defined only by Order By clauses in Select queries which address the table. You need to review relational database basics, (eg https://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch01.html).

If the table had a primary key, you could define a Trigger that sets p_nm column based on the PK, or you could create a View implementing that logic, or in 5.7 and later you could define a derived column using the same logic

Note also that with no primary key, the table isn't a real table.

What problem are you trying to solve by trying to make p_nm values depend on row order?

Options: ReplyQuote


Subject
Views
Written By
Posted
907
January 03, 2018 11:35AM
578
January 03, 2018 01:02PM
876
January 04, 2018 11:49AM
583
January 04, 2018 01:03PM
Re: Declare a table as like MS SQL Server
721
January 04, 2018 05:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.