SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member ectropic's Avatar
    Join Date
    Jul 2003
    Location
    Genoa, OH
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL String Questions

    I want to do some logic in a SQL string that is retrieving just 5 columns or so from a table. I currently have it creating expressions for each used column so it looks readable on a webpage, but I need some more.

    I would like to have it return a string based on teh value of a field. For Example, I have a "ship_to" field with numbers. So I would like it to return "Client" when the number is 1. How can I do this?

    Here is the string I have so far:

    ***
    SELECT [Date] AS Date, CLrace AS Demographic, Bro_type AS [Brochure Type], Bro_NAME AS [Brochure Name], numcopies AS [Number of Copies]
    FROM prud_Pending
    WHERE (Sequence = 9)
    ***

    I know there are other ways I could deal with teh data, but if I could do everything in the SQL string that would help me.
    Last edited by ectropic; Sep 19, 2003 at 11:23.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    " ... if I could do everything in the SQL string ..."

    that's the way i look at things, too

    based on the fact that you're using square brackets to escape your use of reserved words as column names, i'd say you were using microsoft access, so this is what you want --

    select IIF(shipto=1,"Client","notClient") as IsShipToClient

    in other databases, use CASE structure instead of IIF function


    rudy
    http://r937.com/


Bookmarks

Posting Permissions

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