SQL Statement Question

Results 1 to 2 of 2

Thread: SQL Statement Question

  1. #1
    Join Date
    Dec 1969

    Default SQL Statement Question

    I want limit the number of unique entries in one of my columns to 3 for a single user. For example, in this table, User 1 could enter as many records as they like as long as they do not try and create more than 3 unique entries for &#039;WatchListName&#039;. If they were to try and insert another record here with a 4th unique WatchListName value, I would redirect them to another page. Can someone please help me out with the SQL syntax for this kind of statement? Thanks.<BR><BR>UserID WatchListName<BR>1 Turnover <BR>1 Turnover<BR>1 Expenses<BR>1 Funds<BR>1 Expenses<BR>1 Turnover<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL Statement Question

    You should newer have any duplicate records in a table. Add a quantity field which you increment when a user enters new values You can add a check that the value cannot exceed 3 or you could check that in the application.<BR><BR>alter table ogrish add quantity int check (quantity &#060;= 3)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts