I’m not very strong in SQL statements but I would like to know about a thing I’m willing to know.
Imagine a “visible” column that holds ‘y’ or ‘n’ values. Is it possible to have only a single ‘y’ without launching a pre-query that updates this table to ‘n’ value for all rows before setting the desired row to ‘y’?
Thanks in advance.
Assuming you want to set row with ID 123 to be visible, you can do the following. The first query will not update all rows, only the row(s) that are already set to Y:
Another approach is, rather than making Visible a flag, make it a VisibleDate column. Then set that column to the current date for the row you want to be visible. Then, to determine which row is currently visible, select the max date from the VisibleDate column to find the row.