Professional Web Applications Themes

Need help Now - Microsoft SQL / MS SQL Server

I need someone to answer a few questions that I have. Nobody seems to want to help me on the other newsgroup. Can you please answer a few SQL questions? Here are the questions: 1. Say you have a drop down list based on a SQL statement, want limited by the values in another control on the form - how could this be done? 2. Dont need I found the answer for this one. 3. Found this one also 4. Can you join a table to itself? (how? Alias.) 5. What is the diff, between distinct and distinct row? 6. ...

  1. #1

    Default Need help Now

    I need someone to answer a few questions that I have.
    Nobody seems to want to help me on the other newsgroup.

    Can you please answer a few SQL questions?

    Here are the questions:

    1. Say you have a drop down list based on a SQL statement,
    want limited by the values in another control on the form -
    how could this be done?

    2. Dont need I found the answer for this one.

    3. Found this one also

    4. Can you join a table to itself? (how? Alias.)

    5. What is the diff, between distinct and distinct row?

    6. How would you check a value agains a lookup tableA?
    (IN) or is "IN" the answer?


    Troy Guest

  2. #2

    Default Re: Need help Now

    I just need in english how you would check a value against
    a lookup table (IN)?

    What does "(IN)" mean. My boss just wrote it down so I
    dont know if it is part of the question?

    Thank you so much for the above answers. 
    (perhaps you want to 
    table B 
    >I think DISTINCT ROW is syntax of ACCESS , in T-SQL[/ref]
    DISTINCT is the same 
    >Let assume you have two tables
    >SELECT * FROM Table1 WHERE Table1.col NOT IN (SELECT[/ref]
    table2.col FROM Table2 [/ref]
    statement, [/ref]
    form - 
    >
    >
    >.
    >[/ref]
    troy Guest

  3. #3

    Default Re: Need help Now

    Troy
    I don't understand first ,second and third questions (perhaps you want to
    ask VB newsgroup)
    4.> Can you join a table to itself? (how? Alias.)
    SELECT A.<column name>,B.<column name> FROM table A JOIN table B
    ON A.col=B.col 
    I think DISTINCT ROW is syntax of ACCESS , in T-SQL DISTINCT is the same
    as GROUP BY clause. 
    Let assume you have two tables
    SELECT * FROM Table1 WHERE Table1.col NOT IN (SELECT table2.col FROM Table2
    WHERE table1.col=table2.col)

    CREATE TABLE #Demo (
    idNo int identity(1,1),
    colA int,
    colB int
    )

    INSERT INTO #Demo(colA,colB) VALUES (1,6)
    INSERT INTO #Demo(colA,colB) VALUES (1,6)
    INSERT INTO #Demo(colA,colB) VALUES (2,4)
    INSERT INTO #Demo(colA,colB) VALUES (3,3)
    INSERT INTO #Demo(colA,colB) VALUES (4,2)
    INSERT INTO #Demo(colA,colB) VALUES (3,3)
    INSERT INTO #Demo(colA,colB) VALUES (5,1)
    INSERT INTO #Demo(colA,colB) VALUES (8,1)

    PRINT 'Table'
    SELECT * FROM #Demo

    PRINT 'Duplicates in Table'
    SELECT * FROM #Demo
    WHERE idNo IN
    (SELECT B.idNo
    FROM #Demo A JOIN #Demo B
    ON A.idNo <> B.idNo
    AND A.colA = B.colA
    AND A.colB = B.colB)

    PRINT 'Duplicates to Delete'
    SELECT * FROM #Demo
    WHERE idNo IN
    (SELECT B.idNo
    FROM #Demo A JOIN #Demo B
    ON A.idNo < B.idNo -- < this time, not <>
    AND A.colA = B.colA
    AND A.colB = B.colB)

    DELETE FROM #Demo
    WHERE idNo IN
    (SELECT B.idNo
    FROM #Demo A JOIN #Demo B
    ON A.idNo < B.idNo -- < this time, not <>
    AND A.colA = B.colA
    AND A.colB = B.colB)

    PRINT 'Cleaned-up Table'
    SELECT * FROM #Demo

    DROP TABLE #Demo





    "Troy" <com> wrote in message
    news:05eb01c35b05$87139f00$gbl... 


    Uri Guest

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139