Selecting records

Results 1 to 2 of 2

Thread: Selecting records

  1. #1
    Join Date
    Dec 1969

    Default Selecting records

    This is probably a stupid question, but I was wondering how I would take a record from an existing database and display it inside an html form. Then write that that record has been used. <BR><BR>What I am trying to do it select a client number for new record and then not use that one again. And then write this number to another table (I am fine with the second part). Is there a simple way to do this?<BR><BR>Thanks in advance

  2. #2
    Join Date
    Dec 1969

    Default Why not simply add a field... the table that says "AlreadyDisplayed" (a boolean, yes/no true/false field would be enough)? Set it when you display the record.<BR><BR>Then, when you select records, you do<BR><BR>SELECT * FROM table WHERE .... AND AlreadyDisplayed = False ....<BR><BR>But you say you are already creating a table that lists the records you *have* displayed, yes? So why not use *it*??<BR><BR>SELECT * FROM table WHERE .... AND clientNumber NOT IN (<BR>&nbsp; &nbsp; &nbsp; &nbsp; SELECT clientNumber FROM alreadyWrittenTable <BR>&nbsp; &nbsp; &nbsp; &nbsp; )<BR><BR>See that? The "inner" select gets a list of all the numbers already displayed and then the NOT IN clause says "but don&#039;t pick any of these." Really simple and reasonably fast!<BR><BR>Either of these ways seem adequate. If you added the field to the original table, though, you really would not *need* the second table, would you? You could always find the ones that were already written simply by qualifying the query with that added field.<BR><BR><BR>

Posting Permissions

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