SQL conditional statement HELP

Results 1 to 2 of 2

Thread: SQL conditional statement HELP

  1. #1
    Join Date
    Dec 1969

    Default SQL conditional statement HELP

    A form collects user input. One of the fields in the "elements" table is db_pagecolors and can have a value of 1 - 6.<BR>Each one of these values corresponds to additional information about db_pagecolors which are stored in seperate tables (color1, color2, etc..) (within the color tables are field names db_color_sidebar, db_color_topbar, db_color_bg)<BR>I would like to format an SQL statement so that when the info is pulled from the dB, the correct color table is selected based on the number in the db_pagecolors field.<BR><BR>Something to the effect of :<BR>If elements.db_pagecolors = (# 1-6)<BR> Then select * from color(1-6)<BR>End If<BR><BR>The number would have to be "attached" to the word color.<BR>How do I accomplish this ?<BR><BR>Of course this would correspond to a recordset and the info would be laid ou within &#060;HTML&#062; tags.<BR><BR>Thanks in advance !<BR>Nick

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL conditional statement HELP

    Try this:<BR>IF elements.db_pagecolors &#062; 1 AND elements.db_pagecolors &#060; 6 THEN<BR>SQL = "select * from (color" & elements.db_pagecolors & ")"<BR>ELSE<BR>Response.write elements.db_pagecolors & " is not a valid value."<BR>End If<BR><BR>Execute the SQL Statement. You can remove the ELSE Reponse Stmt if you like.

Posting Permissions

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